当前位置: 代码迷 >> J2EE >> 求指点 JDBC 连接oracle出现错误
  详细解决方案

求指点 JDBC 连接oracle出现错误

热度:41   发布时间:2016-04-22 00:31:19.0
求指点 JDBC 连接oracle出现异常
hp win7 32位机子 用的是lomboz eclipse
代码:
import java.sql.*;
public class TestJDBC {

public static void main(String[] args) throws Exception{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn=DriverManager.getConnection("jdbc:thin:oracle:@WIN-8IIJRMTMKAG:1158:ORCL", "liuchao", "liuchao");

}

}
异常:
Exception in thread "main" java.sql.SQLException: No suitable driver found for jdbc:thin:oracle:@WIN-8IIJRMTMKAG:1158:ORCL
at java.sql.DriverManager.getConnection(DriverManager.java:602)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at TestJDBC.main(TestJDBC.java:7)

------解决方案--------------------
jdbc:thin:oracle:@WIN-8IIJRMTMKAG:1158:ORCL错了,
应该是jdbc:oracle:thin:@WIN-8IIJRMTMKAG:1158:orcl吧
------解决方案--------------------
jdbc:oracle:thin:@192.168.3.1:1521:orcl
------解决方案--------------------
你的数据库如果是本地的话就这样, 如果是外地你把localhost换成IP地址就ok啦 jdbc:oracle:thin:@localhost:1521:orcl
------解决方案--------------------
探讨

jdbc:thin:oracle:@WIN-8IIJRMTMKAG:1158:ORCL错了,
应该是jdbc:oracle:thin:@WIN-8IIJRMTMKAG:1158:orcl吧

------解决方案--------------------
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
String url="jdbc:oracle:thin:@localhost:1521:orcl";
//orcl为数据库的SID
String user="test";
String password="test";
Connection conn= DriverManager.getConnection(url,user,password);
------解决方案--------------------
jdbc:thin:oracle:@WIN-8IIJRMTMKAG:1158:ORCL——反了,先oracle在前,jdbc:oracle:thin:@WIN-8IIJRMTMKAG:1158:ORCL
  相关解决方案