I have this code:
Public class DatabaseCon{
private static Connection con;
public static final String user = “user”;
public static final String password = “password”;
public static final String db = “jdbc:derby://localhost:1527/testdb”;
public static Connection getConnection()
if (con == null)
try
{
con = DriverManager. getConnection(db, user, password);
System. out.printin("created connection to " + db + " "+ user + “ “ + password);
System. out.printin("the connection: " + con);
System. out.print ("Current database: " + con.getCatalog());
DatabaseMetaData metaData = con.getMetaData();
String[] types = {"TABLE"}:
ResultSet resultSet = metaData. getTables (null, null,
"g'"', new String[]{"'TABLE"});
ArrayList<String> tables = new ArrayList<String>();
while(resultSet.next()){
String tableName = resultSet.getString("TABLE NAME" ) ;
tables. add (tableName);
System. out.printin(tables);
System. out.println("Tables are done!");
}
System.out.println("url: " + con.getMetaData ().getURL ());
}
It outputs an error saying:
connection is null, creating connection! created connection to jdbc:derby://localhost:1527/testdb java java the connection: org.apache.derby.client.net.NetConnection@7b75baeb Current database: null== Tables Tables are done! url:jdbc:derby://localhost:1527/testdb getConnection is done!
java.sql. SQLSyntaxErrorException: Table/View 'PEOPLE' does not exist.
at org.apache.derby.client.am.SQLExceptionFactory.getSQLException(SQLExceptionFactory.ji
at org.apache. derby.client.am.SqlException.getSQLException (SqlException. java: 325)
at org.apache.derby. client.am. ClientConnection.prepareStatement(ClientConnection.java:4.
If anyone could help please reply