首页上一页 1 下一页尾页 1 条记录 1/1页
JSP项目开发全程实录第二版第一章供求信息网数据库连接问题
发表在JavaWeb图书答疑
2012-04-30
是否精华
是
否
版块置顶:
是
否
项目中有个connDB.properties文件。内容如下:
#DB_CLASS_NAME(驱动的类的类名)
DB_CLASS_NAME=com.microsoft.sqlserver.jdbc.SQLServerDriver
#DB_URL(要连接数据库的地址)
DB_URL=jdbc:mysql://127.0.0.1:3306/db_librarySys?user=root&password=111&useUnicode=true
这个文件有问题吧?不是连接sql2000数据库吗?url怎么是mysql的?还有驱动classname好像也错了吧。我按光盘的配置方法配置完后。在tomcat中部署时提示。创建数据库连接失败。怎么办呢?
[font color=#FF0000]Jar包已导入了。错误提示如下:
创建数据库连接失败!
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.
at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
at com.microsoft.jdbc.sqlserver.tds.TDSConnection.<init>(Unknown Source)
at com.microsoft.jdbc.sqlserver.SQLServerImplConnection.open(Unknown Source)
at com.microsoft.jdbc.base.BaseConnection.getNewImplConnection(Unknown Source)
at com.microsoft.jdbc.base.BaseConnection.open(Unknown Source)
at com.microsoft.jdbc.base.BaseDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at com.yxq.dao.DB.getCon(DB.java:29)
at com.yxq.dao.DB.doPstm(DB.java:43)
at com.yxq.dao.OpDB.OpGetListBox(OpDB.java:21)
at com.yxq.action.IndexAction.<clinit>(IndexAction.java:47)
at sun.misc.Unsafe.ensureClassInitialized(Native Method)
at sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:25)
at sun.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:122)
at java.lang.reflect.Field.acquireFieldAccessor(Field.java:918)
at java.lang.reflect.Field.getFieldAccessor(Field.java:899)
at java.lang.reflect.Field.get(Field.java:358)
at org.apache.catalina.loader.WebappClassLoader.clearReferencesStaticFinal(WebappClassLoader.java:1814)
at org.apache.catalina.loader.WebappClassLoader.clearReferences(WebappClassLoader.java:1718)
at org.apache.catalina.loader.WebappClassLoader.stop(WebappClassLoader.java:1622)
at org.apache.catalina.loader.WebappLoader.stop(WebappLoader.java:710)
at org.apache.catalina.core.StandardContext.stop(StandardContext.java:4649)
at org.apache.catalina.startup.HostConfig.checkResources(HostConfig.java:1236)
at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1342)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:303)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1337)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1601)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1610)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1590)
at java.lang.Thread.run(Thread.java:619)
[/font]
#DB_CLASS_NAME(驱动的类的类名)
DB_CLASS_NAME=com.microsoft.sqlserver.jdbc.SQLServerDriver
#DB_URL(要连接数据库的地址)
DB_URL=jdbc:mysql://127.0.0.1:3306/db_librarySys?user=root&password=111&useUnicode=true
这个文件有问题吧?不是连接sql2000数据库吗?url怎么是mysql的?还有驱动classname好像也错了吧。我按光盘的配置方法配置完后。在tomcat中部署时提示。创建数据库连接失败。怎么办呢?
[font color=#FF0000]Jar包已导入了。错误提示如下:
创建数据库连接失败!
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.
at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
at com.microsoft.jdbc.sqlserver.tds.TDSConnection.<init>(Unknown Source)
at com.microsoft.jdbc.sqlserver.SQLServerImplConnection.open(Unknown Source)
at com.microsoft.jdbc.base.BaseConnection.getNewImplConnection(Unknown Source)
at com.microsoft.jdbc.base.BaseConnection.open(Unknown Source)
at com.microsoft.jdbc.base.BaseDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at com.yxq.dao.DB.getCon(DB.java:29)
at com.yxq.dao.DB.doPstm(DB.java:43)
at com.yxq.dao.OpDB.OpGetListBox(OpDB.java:21)
at com.yxq.action.IndexAction.<clinit>(IndexAction.java:47)
at sun.misc.Unsafe.ensureClassInitialized(Native Method)
at sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:25)
at sun.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:122)
at java.lang.reflect.Field.acquireFieldAccessor(Field.java:918)
at java.lang.reflect.Field.getFieldAccessor(Field.java:899)
at java.lang.reflect.Field.get(Field.java:358)
at org.apache.catalina.loader.WebappClassLoader.clearReferencesStaticFinal(WebappClassLoader.java:1814)
at org.apache.catalina.loader.WebappClassLoader.clearReferences(WebappClassLoader.java:1718)
at org.apache.catalina.loader.WebappClassLoader.stop(WebappClassLoader.java:1622)
at org.apache.catalina.loader.WebappLoader.stop(WebappLoader.java:710)
at org.apache.catalina.core.StandardContext.stop(StandardContext.java:4649)
at org.apache.catalina.startup.HostConfig.checkResources(HostConfig.java:1236)
at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1342)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:303)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1337)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1601)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1610)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1590)
at java.lang.Thread.run(Thread.java:619)
[/font]