主题:好大问题
import java.sql.*;
import javax.swing.*;
public class test1 {
Connection conn;
Statement st;
ResultSet rs;
public test1()
{
try{
String name="com.microsoft.jdbc.sqlserver.SQLServerDriver";
String url="jdbc:microsoft:sqlserver://localhost:80;DatabaseName=master" ;
Class.forName(name);
conn=DriverManager.getConnection(url,"sa","");
st = conn.createStatement();
rs = st.executeQuery("SELECT * from systypes");
while(rs.next())
{
System.out.print(rs.getString("name") + " ");
System.out.println(rs.getInt("xtype"));
}
System.out.println("Ok");
conn.close();
}catch(Exception e)
{
e.printStackTrace();
}
}
public static void main(String[] args)
{
test1 cs=new test1();
}
}
我试用这个程序连接数据库
但总是有问题
java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:164)
at test1.<init>(test1.java:12)
at test1.main(test1.java:32)
Press any key to continue...
我的环境配置应该不错的 我还装了SQL2000-KB884525-SP4-x86-CHS.EXE 升级了还是一样的
可是就是不行 求教呀?
有谁可以解决下我的问题呢?
import javax.swing.*;
public class test1 {
Connection conn;
Statement st;
ResultSet rs;
public test1()
{
try{
String name="com.microsoft.jdbc.sqlserver.SQLServerDriver";
String url="jdbc:microsoft:sqlserver://localhost:80;DatabaseName=master" ;
Class.forName(name);
conn=DriverManager.getConnection(url,"sa","");
st = conn.createStatement();
rs = st.executeQuery("SELECT * from systypes");
while(rs.next())
{
System.out.print(rs.getString("name") + " ");
System.out.println(rs.getInt("xtype"));
}
System.out.println("Ok");
conn.close();
}catch(Exception e)
{
e.printStackTrace();
}
}
public static void main(String[] args)
{
test1 cs=new test1();
}
}
我试用这个程序连接数据库
但总是有问题
java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:164)
at test1.<init>(test1.java:12)
at test1.main(test1.java:32)
Press any key to continue...
我的环境配置应该不错的 我还装了SQL2000-KB884525-SP4-x86-CHS.EXE 升级了还是一样的
可是就是不行 求教呀?
有谁可以解决下我的问题呢?