In my Java application I have written a class that starts the Derby database server programmatically.
Can I also write a new class that uses JDBC to create a new Derby database from raw Java code rather than going through the Netbeans prompts to set up the derby database?
In my research I have found the CREATE DATABASE sql statement but I can not get this to work. Here is the code I have so far:
public class DbConnect
{
   String host = "jdbc:derby://localhost:1527/";
   String userName = "fam";
   String password = "fam";
   public static Connection con;
   Statement s;
   static final String drive = "com.derby.jdbc.Driver";
   protected DbConnect()  { }
   public void getDBConnection(Connection con)
   {
      try
      {   
         s = con.createStatement();
         String newDB = "CREATE  DATABASE NEWDB";
         s.executeUpdate(newDB);
         String host = "jdbc:derby://localhost:1527/NEWDB";
         String userName = "fam";
         String password = "fam";
         con = DriverManager.getConnection(host, userName, userName);
      }
      catch(SQLException err)
      {    
         System.out.print(err.getMessage());
      } 
 }
