在Windows中的Netbeans / Glassfish上添加jdbc驱动程序的位置? [英] Where to add the jdbc driver on Netbeans/Glassfish in Windows?

查看:103
本文介绍了在Windows中的Netbeans / Glassfish上添加jdbc驱动程序的位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在Netbeans 6.8中创建的企业应用程序,它与Glassfish V3服务器一起打包。当我尝试部署并运行EAR项目时,我从服务器日志中收到以下异常:

I have an enterprise app created in Netbeans 6.8 which comes packaged with a Glassfish V3 server. I've been receiving the following exception from the server log when I try to deploy and run the EAR project:

SEVERE: jdbc.exc_cnfe_ds
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

来自谷歌搜索,常见的解决方法是将包含该类的jar文件(mysql-connector-java-5.1.6-bin.jar)复制到

From googling, the common solution to this is to copy the jar file (mysql-connector-java-5.1.6-bin.jar) containing that class to

$glassfish-v3-install-root/glassfish/domains/domain1/lib.

实际上它就是它驻留在Unix服务器上的地方。但是,我在Windows上测试它,并且默认的glassfish安装中不存在domains / domain1目录。我手动添加它们并添加了jar,但它没有任何区别。我还将jar作为变量添加到windows类路径中,但这也没有效果。

and in fact that's where it resides on the Unix server. However, I'm testing this on windows and the "domains/domain1" directories don't exist in the default glassfish install. I added them manually and added the jar, but it made no difference. I also added the jar as a variable to the windows classpath, but that also had no effect.

然后我尝试添加jar文件$ glassfish-v3-install-root / glassfish / lib,这产生了一个不同的错误:

I then tried adding the jar file $glassfish-v3-install-root/glassfish/lib, and that produced a different error:

SEVERE:RAR5111:转换为javax.sql.Datasource时出错
java.lang.ClassCastException:com .mysql.jdbc.Driver无法强制转换为javax.sql.DataSource

SEVERE: RAR5111 : Error casting to javax.sql.Datasource java.lang.ClassCastException: com.mysql.jdbc.Driver cannot be cast to javax.sql.DataSource

我使用与服务器相同的jar文件。我猜这个罐子放错了地方?我不想把它放在项目中,因为这不是它在生产中的部署方式。任何帮助赞赏。

I'm using the same jar file as exists for the server. I'm guessing the jar is misplaced? I don't want to put it in the project because that's not how it's deployed in production. Any help appreciated.

推荐答案

将jar文件放在$ glassfish-v3-install-root / glassfish / lib中证明是正确的。

Putting the jar file in $glassfish-v3-install-root/glassfish/lib turned out to be correct.

"SEVERE: RAR5111 : Error casting to javax.sql.Datasource java.lang.ClassCastException: com.mysql.jdbc.Driver cannot be cast to javax.sql.DataSource"


$ b我认为,$ b

错误是由于glassfish服务器上的jdbc池设置不正确造成的。但是转到管理控制台,可从Netbeans服务器选项卡获取,转到JDBC,连接池,选择java.sql.driver作为资源类型和com.mysql.jdbc.driver因为驱动程序类名将摆脱铸造问题。

error was, I believe, caused by an incorrect setting for the jdbc pooling on the glassfish server. But going to the admin console, available from the Netbeans "server" tab, going to the "JDBC", "Connection Pools", select "java.sql.driver" as the resource type and "com.mysql.jdbc.driver" as the driver classname will get rid of the casting issue.

单击顶部附近的Ping按钮以确保连接。

Click the "Ping" button near the top to make sure you're connecting.

这篇关于在Windows中的Netbeans / Glassfish上添加jdbc驱动程序的位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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