简体   繁体   English

java.sql.SQLException:无法启动数据库

[英]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.

相关问题 java.sql.SQLException:使用MS Access数据库找不到数据 - java.sql.SQLException: No data found with MS Access database java.sql.SQLException:在SWT中使用时数据库被锁定 - java.sql.SQLException: database is locked while using in SWT Phpstorm数据库:java.sql.SQLException:通信链接失败 - Phpstorm Database : java.sql.SQLException: Communications link failure 首次连接到Netbeans SQL数据库 - java.sql.SQLException:找不到合适的驱动程序0 08001 - Connecting to Netbeans SQL Database for the first time - java.sql.SQLException: No suitable driver found 0 08001 java.sql.SQLException: 找不到适合 jdbc:mysql://localhost:3306/database 的驱动程序 - java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/database java.sql.SQLException:ORA-00942:表或视图不存在,每三分之一命中数据库 - java.sql.SQLException: ORA-00942: table or view does not exist, getting in every third hit to database 错误java.sql.SQLException:从数据库中检索Blob(图像)时,SQLite JDBC驱动程序未实现 - Error java.sql.SQLException: not implemented by SQLite JDBC driver when Retrieving Blob (Image) from Database 获取“ java.sql.SQLException:值未绑定到语句”异常 - Getting “java.sql.SQLException: Values not bound to statement” exception 错误java.sql.SQLException:接近“ - ”:语法错误 - ERROR java.sql.SQLException: near “-”: syntax error Hibernate java.sql.SQLException:未为参数1指定值 - Hibernate java.sql.SQLException: No value specified for parameter 1
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM