Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Database/JDBC/SQL/JDO/Hibernate  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 做毕业设计用JDBC-ODBC连接数据库,遇到了一个非常棘手的问题,还请各位高手给予指点。
yyp91





发贴: 2
积分: 0
于 2006-04-13 16:43 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
各位高手,我现在在做毕业设计,遇到了一个非常棘手的问题,我调试了快一个星期了,还是没有解决问题,还请各位高手给予指点。
我用的是SQL SERVER 2000 ,系统是WINXP SP-2
我设置的环境变量classpath为:C:\Borland\JBuilder2005\jdk1.4\lib;.;C:\Program Files\Tomcat 5.0\common\lib;.;
用的是JDBC-ODBC连接桥连接数据库,原代码如下:
package hospital.db;

import java.sql.*;
import hospital.db.*;

public abstract class DBConnection
{
private static Connection conn = null;
public static Connection getConnection()
{
try
{
if(conn == null)
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conn = DriverManager.getConnection("jdbc:odbc:shujuku","sa","");
System.out.println("Connection created.");
}
else
{
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("select countStart from administrator");
if(rs == null || !rs.next())
{
Class.forName("san.jdbc.odbc.JdbcOdbcDriver");
conn = DriverManager.getConnection("jdbc:odbc:shujuku","sa","");
System.out.println("Connection re-created.");
}
}
catch(Exception ex)
{
System.out.println(ex);
}
finally
{
return conn;
}
}
}

数据库连接问题不不大:Connection created. 2006-04-12 11:34:33
但是放在Tomcat 5.0中总是抛出异常为:
sun.jdbc.odbc.JdbcOdbc.createSQLException() Ln6958[Microsoft][ODBC SQL Server Driver]连接占线导致另一个 hstmt 2006-04-12 11:34:33

还请高手指点迷津!!!!不甚感激!



作者 Re:做毕业设计用JDBC-ODBC连接数据库,遇到了一个 [Re:yyp91]
liangx





发贴: 37
积分: 0
于 2006-06-30 18:55 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
为什么不试试微软提供的jdbc驱动阿



flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923