[英]java.sql.SQLException: Failed to start database
First, this is my first time with Apache Derby. 首先,这是我第一次使用Apache Derby。 I am using netbeans, willing to use embedded apache derby but it showing following exception 我正在使用netbeans,愿意使用嵌入式apache derby,但显示以下异常
enter code here
String url="jdbc:derby:C:/Users/ankit/.netbeans-derby/kushal11";
try
{
Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
con=DriverManager.getConnection(url,"APP","APP");
} catch(Exception e){ System.out.println(e);}
try {
PreparedStatement pstmt1 =
con.prepareStatement("select COUNT(*) as c from cus_details where cust_name='"+s1+"'");
ResultSet executeQuery = pstmt1.executeQuery();
int a=0;
while (executeQuery.next()){
a=executeQuery.getInt("c");
System.out.print(a);
}
But, when I am trying to insert data into the database, it is giving me the following error 但是,当我尝试将数据插入数据库时,它给了我以下错误
enter code here
java.sql.SQLException: Failed to start database 'C:/Users/ankit/.netbeans-derby/kushal11' with class loader sun.misc.Launcher$AppClassLoader@9fef6f, see the next exception for details. java.sql.SQLException:无法使用类加载器sun.misc.Launcher$AppClassLoader@9fef6f启动数据库'C:/Users/ankit/.netbeans-derby/kushal11',有关详细信息,请参见下一个异常。
You may want to declare 您可能要声明
Connection con = DriverManager.getConnection(url);
I don't know if you did declare it, but in your code you just have con without declaring it with Connection 我不知道您是否声明了它,但是在您的代码中只是使用con而不用Connection声明它
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.