我做了一个测试在swt和java中是正确的但当放入rcp中调用出现错误提示!!!
连接器
import java.sql.Connection;
public class ConnectionDB {
public ConnectionDB(){}
public ConnectionDB(String driver,String dburl,String userName,String password){
}
public Connection getConnection(){
// Declare the JDBC objects.
Connection con = null;
try {
// Establish the connection.
com.microsoft.sqlserver.jdbc.SQLServerDataSource ds = new com.microsoft.sqlserver.jdbc.SQLServerDataSource();
ds.setIntegratedSecurity(true);
ds.setServerName("localhost");
ds.setPortNumber(1433);
ds.setDatabaseName("binya");
ds.setUser("sa");
ds.setPassword("3110154576");
con = ds.getConnection();
} catch (Exception e){
e.printStackTrace();
}
return con;
}
}
java、swt测试:
import java.sql.*;
import com.hy.archive.db.ConnectionDB;
public class ConnectTest {
public static void main(String[] args) {
// Declare the JDBC objects.
Connection con = new ConnectionDB().getConnection();
try{
System.out.println("ok");
con.close();
}catch(Exception e){
e.printStackTrace();
}
}
}
测试正确
放入rcp出现如下错误:
try {
UIStats.start(UIStats.CREATE_PART_CONTROL, label);
view.createPartControl(content);
parent.layout(true);
} finally {
UIStats.end(UIStats.CREATE_PART_CONTROL, view, label); -----------
}
无法创建视图:com/microsoft/sqlserver/jdbc/SQLServerDataSource
什么原因呢?