JDBC怎么连SQL~
谁会用JDBC与SQL2005连.!
3个包莪下了.担不知道怎么导.!
而且莪的工具还是英文的~JBuilder 2005~找不到汉化包.!跪求高手指点吖!!!!
莪的SQL是2005的.~以下是代码
Connection con;
Statement st;
ResultSet rs;
String url = "jdbc:microsotf:sqlserver://";
String serverName = "localhost";
String portNumber = "1433";
String databaseName = "test";
String userName = "sa";
String password = "123456";
public Conn() {
}
String getconn() {
return url + serverName + ";" + portNumber + ";databaserName=" +
databaseName + ";";
}
Connection getCon() {
try {
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
con = DriverManager.getConnection(getconn(), userName, password);
if (con != null) {
System.out.println("OK");
}
} catch (Exception ex) {
ex.printStackTrace();
System.out.println("getconn()Sorry" + ex.getMessage());
}
return con;
}
下面是报错代码:
D:\Borland\JBuilder2005\jdk1.4\bin\javaw -classpath "C:\Tel\classes;D:\Borland\JBuilder2005\jdk1.4\jre\javaws\javaws.jar;D:\Borland\JBuilder2005\jdk1.4\jre\lib\charsets.jar;D:\Borland\JBuilder2005\jdk1.4\jre\lib\ext\dnsns.jar;D:\Borland\JBuilder2005\jdk1.4\jre\lib\ext\ldapsec.jar;D:\Borland\JBuilder2005\jdk1.4\jre\lib\ext\localedata.jar;D:\Borland\JBuilder2005\jdk1.4\jre\lib\ext\sunjce_provider.jar;D:\Borland\JBuilder2005\jdk1.4\jre\lib\im\indicim.jar;D:\Borland\JBuilder2005\jdk1.4\jre\lib\im\thaiim.jar;D:\Borland\JBuilder2005\jdk1.4\jre\lib\jce.jar;D:\Borland\JBuilder2005\jdk1.4\jre\lib\jsse.jar;D:\Borland\JBuilder2005\jdk1.4\jre\lib\plugin.jar;D:\Borland\JBuilder2005\jdk1.4\jre\lib\rt.jar;D:\Borland\JBuilder2005\jdk1.4\jre\lib\sunrsasign.jar;D:\Borland\JBuilder2005\jdk1.4\lib\dt.jar;D:\Borland\JBuilder2005\jdk1.4\lib\htmlconverter.jar;D:\Borland\JBuilder2005\jdk1.4\lib\tools.jar" tel.TelApp
java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver at java.net.URLClassLoader$1.run(URLClassLoader.java:199)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:141)
at tel.Conn.getCon(Conn.java:39)
at tel.TelFrame.display(TelFrame.java:101)
at tel.TelFrame.DengLu_actionPerformed(TelFrame.java:119)
at tel.TelFrame_DengLu_actionAdapter.actionPerformed(TelFrame.java:146)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1786)
at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1839)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:245)