主题:这是个什么错误?
[Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.
代码如下:
package com.xaccp.jdbc;
import java.sql.*;
import javax.swing.*;
public class Test {
public static void main(String[] args) {
try {
// 加载驱动
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
// 建立链接
Connection con = DriverManager.getConnection(
"jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=bbs",
"sa", "");
// 获取操作对象
Statement stm=con.createStatement();
// stm.executeUpdate("insert admin values('haha','heihei')");
int n=stm.executeUpdate("delete from admin where id=3");
JOptionPane.showMessageDialog(null,"操作成功!");
} catch (SQLException ex) {
System.out.println(ex.getMessage());
} catch (ClassNotFoundException ex) {
System.out.println(ex.getMessage());
}
}
}
代码如下:
package com.xaccp.jdbc;
import java.sql.*;
import javax.swing.*;
public class Test {
public static void main(String[] args) {
try {
// 加载驱动
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
// 建立链接
Connection con = DriverManager.getConnection(
"jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=bbs",
"sa", "");
// 获取操作对象
Statement stm=con.createStatement();
// stm.executeUpdate("insert admin values('haha','heihei')");
int n=stm.executeUpdate("delete from admin where id=3");
JOptionPane.showMessageDialog(null,"操作成功!");
} catch (SQLException ex) {
System.out.println(ex.getMessage());
} catch (ClassNotFoundException ex) {
System.out.println(ex.getMessage());
}
}
}