我试图连接到我的本地数据库
当我尝试netbeans IDE时,给我这个错误:
java.sql.SQLException:找不到合适的驱动程序 JDBC:预言:OCI:@ d3do3a:1521:XE
这是我的tnsname.ora
文件:
XE =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = d3do3a)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = XE)
)
)
EXTPROC_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
)
(CONNECT_DATA =
(SID = PLSExtProc)
(PRESENTATION = RO)
)
)
这是我的主要方法:
public static void main(String[] args) {
// TODO code application logic here
Connection myConn =null;
Statement myStmt =null;
ResultSet myRs =null;
String user ="doaa";
String pass ="0563014554";
try {
myConn = DriverManager.getConnection("jdbc:oracle:oci:@d3do3a:1521:XE" , user ,pass);
} catch (SQLException ex) {
//Logger.getLogger(NewDatabase.class.getName()).log(Level.SEVERE, null, ex);
ex.printStackTrace();
}
}
}
请问我的数据库网址是否正确或是什么错误???
答案 0 :(得分:1)
为了让JDBC找到你的驱动程序,你需要做两件事:
问题可能是您没有将驱动程序jar添加到类路径中。