Derby当部署为可执行jar时不连接,但在Jdeveloper中工作正常 [英] Derby Database not connecting when deployed as a an executable jar but works fine in Jdeveloper

查看:146
本文介绍了Derby当部署为可执行jar时不连接,但在Jdeveloper中工作正常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的Java程序有一个问题,当我在JDeveloper中运行应用程序时,该程序工作正常,它正确连接到德比数据库。
当我创建一个可执行的jar我得到以下错误没有找到适合的驱动程序jdbc:derby:// localhost:1527 / c:.... / dbcam



我试过下面的

  {public void DoConnect3(){

try {
Class.forName(org.apache.derby.jdbc.EmbeddedDriver);
//连接到数据库
// String host =jdbc:derby:// localhost:1527 / dbCam;
// String host =jdbc:derby:// localhost:1527 / C:/ Users / nasir / SkyDrive / Java / db_Backup / dbCam;
String host =jdbc:derby:// localhost:1527 / C:/Users/nasir/.netbeans-derby/dbCam;
String uName =userCam;
String uPass =cam;
con = DriverManager.getConnection(host,uName,uPass);
stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
// String sql =SELECT * FROM tableCustomer;
String sql =SELECT * FROM tableTroubleshooting;
// String tsss = Integer.toString(tss);
// String sql =SELECT * FROM tableTroubleshooting where ProbID+'+ tsss +';
rs = stmt.executeQuery(sql);
rs.next();

}



感谢

解决方案

您使用的网址是ClientDriver网址,而不是EmbeddedDriver网址。您需要添加正确的jar并加载正确的驱动程序。



HTH



D


Hi I have a problem with my Java program, when I run the application within JDeveloper, the program works fine, it connects to the derby database properly. When I create a executable jar i get the following error no suitable driver found for jdbc:derby://localhost:1527/c:..../dbcam

i have tried the following

    { public void DoConnect3( ) {

  try {
       Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
       // conenct to the database
      // String host ="jdbc:derby://localhost:1527/dbCam";
       //String host ="jdbc:derby://localhost:1527/C:/Users/nasir/SkyDrive/Java/db_Backup/dbCam";
       String host ="jdbc:derby://localhost:1527/C:/Users/nasir/.netbeans-derby/dbCam";
       String uName ="userCam";
       String uPass ="cam";
       con = DriverManager.getConnection(host,uName,uPass);
       stmt = con.createStatement( ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE );
       //String sql = "SELECT * FROM tableCustomer";
       String sql = "SELECT * FROM tableTroubleshooting";
       //String tsss = Integer.toString(tss);
       //String sql = "SELECT * FROM tableTroubleshooting where ProbID  "+"'"+tsss+"'";
        rs = stmt.executeQuery(sql);
       rs.next();

   }

That still doesn't do much only shows me message saying org.apache.derby.clientdriver.

Any suggestions would be gratefully appreciated.

Thanks

解决方案

The url you're using is a ClientDriver url, not an EmbeddedDriver url. You need to add the correct jar and load the correct driver.

HTH

D

这篇关于Derby当部署为可执行jar时不连接,但在Jdeveloper中工作正常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆