Topic: [database] JDBC with M$ SQL Server (including Error establishing socket)

  Print this page

1.[database] JDBC with M$ SQL Server (including Error establishing socket) Copy to clipboard
Posted by: why
Posted on: 2005-12-04 06:52

0. Read, please read JDBC programming 101, before asking questions about JDBC programming with M$ SQL Server.


1. use jTDS if possible http://jtds.sf.net
http://www.cjsdn.net/post/view?bid=10&id=162184

1a. Consider not to use the 3 M$ JDBC jars at its C:\Program Files\... folder, but from somewhere with a straight-forward folder name (i.e. shorter and without spaces).


2. Install M$ SQL Server SP3a, not SP3.
(I have no experience with M$ SQL Server 2000 SP4)

2a. Consider changing to another port other than the default one, 1433.


3. Error establishing socket & issues with Windows XP SP2
Here're the official responses from M$ :
http://support.microsoft.com/kb/313178
How to configure Windows XP Service Pack 2 (SP2) for use with SQL Server
http://support.microsoft.com/kb/841249
How to enable SQL Server connectivity on Windows XP Service Pack 2
http://support.microsoft.com/kb/841251
How to manually enable TCP/IP on Windows XP Service Pack 2 for SQL Server 2000
http://support.microsoft.com/kb/841252

... TBC

2.Re:[database] JDBC with M$ SQL Server (including Error establishing socket) [Re: why] Copy to clipboard
Posted by: why
Posted on: 2005-12-26 19:04

Database Connection Issues, Solutions and Workarounds
http://dev.mainsoft.com/Default.aspx?tabid=150
(see http://www.cjsdn.net/post/view?bid=10&id=166429&sty=3&age=0&tpg=1&ppg=1#166429 )

3.Re:[database] JDBC with M$ SQL Server (including Error establishing socket) [Re: why] Copy to clipboard
Posted by: xcj84311
Posted on: 2006-01-09 17:14

我安装的MSSQL 2000 个人版,操作系统是XPSP2.安装MS SQL 2000 采用默认路径. 如果JDBC在连接时如果出现 NO SUITABLE DRIVER
就将Microsoft SQL Server 2000 Driver for JDBC SP3安装上.将你安装文件夹LIB下的msbase.jar,mssqlserver.jar,msutil.jar三个文件加到类路径中即将CLASSPATH设置为
C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\msbase.jar;C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\mssqlserver.jar;C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\msutil.jar;E:\java\bao\*.*;我的安装都是默认安装所以路径有点长啊.
如果还出现 Error establishing socket异常,那么就安装MS SQL SERVER2000的补丁.我建议最好安装sql server pack sp3,SP4可能i不行.安装的文件名是chs_sql2ksp3.exe.安装后就可以用了,如果你是使用JCRETOR编辑器编辑的话运行还是会出现如下错误:
java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver
at java.net.URLClassLoader$1.run(URLClassLoader.java:198)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:186)
at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:265)
at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:140)
at a.main(a.java:8)
但是如果在CMD(命令行方式运行时)将会显示:
E:\java>java a
regeister driver success
[Microsoft][SQLServer 2000 Driver for JDBC]Database changed to student
[Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]已将数据库上下文改为 'stud
ent'。
[Microsoft][SQLServer 2000 Driver for JDBC]Language changed to 简体中文
[Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]已将语言设置改为 简体中文

1 98.0
5 98.0
5 90.0
1 12.0
恭喜你,成功了.

4.Re:[database] JDBC with M$ SQL Server (including Error establishing socket) [Re: xcj84311] Copy to clipboard
Posted by: why
Posted on: 2006-01-09 21:14

xcj84311 wrote:
将CLASSPATH设置为
C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\msbase.jar;C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\mssqlserver.jar;C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\msutil.jar;E:\java\bao\*.*;我的安装都是默认安装所以路径有点长啊.

You could move the 3 jars to another folder with a shorter path.
E:\java\bao\*.* ?? Are you sure this works?

如果你是使用JCRETOR编辑器编辑的话运行还是会出现如下错误:
java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver
at java.net.URLClassLoader$1.run(URLClassLoader.java:198)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:186)
at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:265)
at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:140)
at a.main(a.java: 8 )

You may want to show us the source code of a.java (BTW, bad class name).
I'm wondering whether this is a question.

Does JCreator (not JCRETOR, I suppose) us system's CLASSPATH automatically? I think you should set it properly in JCreator.


   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