1

I want to create embedded database using JavaDB derby and create a table inside it, Program works fine inside NetBeans when run the program and every thing went OK, when I build the program and run it outside NetBeans the program creates the database but not the table.

I have this error:

error message screenshot

My code:

package doctor;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Connection;

public class CreateDB {  
    public static final String DRIVER =org.apache.derby.jdbc.EmbeddedDriver";  
    public static final String JDBC_URL = "jdbc:derby:nadb;create=true";
    public static void  main(String[] args) throws ClassNotFoundException, SQLException{
       Class.forName(DRIVER); 
       Connection connection = DriverManager.getConnection(JDBC_URL);
       connection.createStatement().execute("create table MYPATIENT(Name varchar(50), Age varchar(2), MOBILENUMBER varchar(50) ,Email varchar(50), Address varchar(200) , Notes varchar(500))"); 
    }
}
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
ahmadx
  • 11
  • 2
  • See this answer for three common reasons for "table does not exist":http://stackoverflow.com/questions/22996818/is-it-necessary-to-create-tables-each-time-you-connect-the-derby-database/23051822#23051822 – Bryan Pendleton Apr 30 '16 at 15:10
  • Possible duplicate of [Is it necessary to create tables each time you connect the derby database?](http://stackoverflow.com/questions/22996818/is-it-necessary-to-create-tables-each-time-you-connect-the-derby-database) – Brian Tompsett - 汤莱恩 Feb 13 '17 at 21:06

0 Answers0