这几天我一头雾水搞不清楚为什么,我用的是XP系统,TOMCAT5.0服务器,JDBC 用的是SQL Server 2000 Driver for JDBC Service Pack 3,可连接SQLServer 2000 时老连不上出现[Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.错误,请求高手帮助,非常感谢!!!
代码如下:
import java.sql.*;
import java.io.*;
public class test
{
public static void main(String arg[]) throws Exception{
Connection con=null;
try{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
con=DriverManager.getConnection("jdbc:microsoft:sqlserver://127.0.0.1:1433","sa","123456");
CallableStatement stmt=con.prepareCall("{call sp_adduser(?,?,?,?)}");
stmt.registerOutParameter(4,Types.INTEGER,1);
stmt.setString(1,"小红");
stmt.setInt(2,2);
stmt.setString(3,"小李你好");
stmt.execute();
int userid=stmt.getInt(4);
stmt.close();
System.out.println("输出的用户ID是:"+ userid);
}catch(ClassNotFoundException e){
System.out.println("class not finded");
}catch(SQLException e){
System.out.println(e.getMessage());
}finally{
try{
if(con!=null) con.close(); }catch(Exception e){
}
}
}
}
代码如下:
import java.sql.*;
import java.io.*;
public class test
{
public static void main(String arg[]) throws Exception{
Connection con=null;
try{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
con=DriverManager.getConnection("jdbc:microsoft:sqlserver://127.0.0.1:1433","sa","123456");
CallableStatement stmt=con.prepareCall("{call sp_adduser(?,?,?,?)}");
stmt.registerOutParameter(4,Types.INTEGER,1);
stmt.setString(1,"小红");
stmt.setInt(2,2);
stmt.setString(3,"小李你好");
stmt.execute();
int userid=stmt.getInt(4);
stmt.close();
System.out.println("输出的用户ID是:"+ userid);
}catch(ClassNotFoundException e){
System.out.println("class not finded");
}catch(SQLException e){
System.out.println(e.getMessage());
}finally{
try{
if(con!=null) con.close(); }catch(Exception e){
}
}
}
}
解决方案 »
- java中 -i 表示什么
- BufferedReader无法完整读取txt文件
- 邮箱点打印的时候图片显示X号
- 写java用什么最好,最方便
- 我的程序在jBuilder中运行可以发出邮件,打了包就发不出邮件了,为什么啊
- 新手编了这一段小代码,但是为什么在输入卡号界面按了返回之后在欢迎界面按继续,就会输出两次cont也就是触发了两次cont事件呢??求解决方法·····
- servlet找不到?!
- 我浏览贴子的时候怎么变成了小框框?
- 如何使用JBuilder
- 请问这是什么错误??
- 小菜问老鸟的一个问题!
- 我是初学者,请问像C中我们可以用scanf语句将一个数组从键盘输入,在JAVA中我该怎么实现呢?
sqlsever打上sp3补丁