JDBC桥连接问题
我的程序报以下错误:Exception in thread "main" java.lang.NoClassDeFoundError:DBAccess<wrong name: connection/DBAccess>
at java.lang.ClassLoader.defineClass1<Native Method>
at java.lang.ClassLoader.defineClass<Unknown Source>
at java.secirotu.SecureClassLoader.defineClass<Unknown Source>
at Source>
at Source>
at java.security.AccessController.doPrivileged<Native Method>
at Source>
at sun.misc.Launcher$AppClassLoader.loader.loadCladd<Unknown Source>
我的代码如下:
package connection;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
public class DBAccess {
Connection con=null;
PreparedStatement sta=null;
ResultSet rs=null;
public DBAccess(){
try{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
}catch(ClassNotFoundException e){
e.printStackTrace();
System.out.println("驱动未找到");
}
}
public void open(){
try{
con=DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost;databasename=test","","");
if(!con.isClosed()){
System.out.println("连接成功!");//显示是否连接成功
}
}catch(SQLException e){
e.printStackTrace();
System.out.println("数据库未能连接!");
}
}
public static void main(String[] args){
DBAccess dta=new DBAccess();
dta.open();
}
}
希望得到各位的帮忙,先谢了!