Fix addAnswer
This commit is contained in:
parent
e93f3980f2
commit
5abb06ef58
1 changed files with 41 additions and 36 deletions
|
@ -1,4 +1,5 @@
|
|||
package servlet;
|
||||
|
||||
import java.sql.*;
|
||||
|
||||
/*
|
||||
|
@ -6,16 +7,19 @@ import java.sql.*;
|
|||
*/
|
||||
public class Database implements AutoCloseable {
|
||||
|
||||
// If you have the mysql server on your own computer use "localhost" as server address.
|
||||
// If you have the mysql server on your own computer use "localhost" as server
|
||||
// address.
|
||||
private static String databaseServerAddress = "vm26.cs.lth.se";
|
||||
private static String databaseUser = "<your databse user on vm26>"; // database login user
|
||||
private static String databasePassword = "<your password>"; // database login password
|
||||
private static String database = "<your database, normally the same as database user>"; // the database to use, i.e. default schema
|
||||
private static String database = "<your database, normally the same as database user>"; // the database to use, i.e.
|
||||
// default schema
|
||||
private Connection conn = null;
|
||||
|
||||
public Database() {
|
||||
try {
|
||||
conn = DriverManager.getConnection("jdbc:sqlite:/home/thugborean/Documents/projects/java/etsf20-test/lab.db3");
|
||||
conn = DriverManager
|
||||
.getConnection("jdbc:sqlite:/home/thugborean/Documents/projects/java/etsf20-test/lab.db3");
|
||||
|
||||
// Display the contents of the database in the console.
|
||||
// This should be removed in the final version
|
||||
|
@ -60,6 +64,7 @@ public class Database implements AutoCloseable {
|
|||
ps.setString(3, answerThree);
|
||||
ps.setString(4, answerFour);
|
||||
ps.setString(5, name);
|
||||
ps.executeUpdate();
|
||||
return true;
|
||||
} catch (SQLException e) {
|
||||
if (e.getErrorCode() == 1062 && e.getSQLState().equals("23000")) {
|
||||
|
|
Loading…
Reference in a new issue