我试图启动数据库并在其中创建一个表,但由于某种原因,我继续运行catch语句而不是加载驱动程序:
servlet:
!important
处理jsp,它由索引html文件上的按钮调用。
public class dbintial {
Connection con = null;
Statement stat = null;
public String driver = "org.apache.derby.jdbc.EmbeddedDriver";
public dbintial() {
System.out.println("intialized");
try {
System.out.println("intialized");
Class.forName(driver);
System.out.println("driver loaded");
//get connection
con = DriverManager.getConnection("jdbc:derby:/Users/Hady/Downloads/v5/web/hady;create=true");
System.out.println("Connected");
//create statement
stat = con.createStatement();
System.out.println("Stat created");
//stat.executeUpdate("CREATE table user5");
stat.executeUpdate("create table user22s34 (email varchar(25), password varchar(25), "
+ "username varchar(25), primary key(email))");
System.out.println("Stat executed");
} catch (ClassNotFoundException ex) {
ex.printStackTrace();
//Logger.getLogger(dbintial.class.getName()).log(Level.SEVERE, null, ex);
System.out.println("1");
} catch (SQLException ex) {
ex.printStackTrace();
// Logger.getLogger(dbintial.class.getName()).log(Level.SEVERE, null, ex);
System.out.println("2");
}
try {
con.close();
}
catch (SQLException e){
e.printStackTrace();
}
}
我安装了所有罐子。在Apache服务器上运行。