当前位置: 技术问答>java相关
JDBC 以thin方式连接Oracle时总报错
来源: 互联网 发布时间:2015-08-02
本文导语: 本机环境:win2k+java 开发工具:jbuilder5 数据库:oracle8.1.7 代码如下: import java.sql.*; public class t3 { public t3() { } public static void main(String[] args) { t3 t31 = new t3(); String d...
本机环境:win2k+java
开发工具:jbuilder5
数据库:oracle8.1.7
代码如下:
import java.sql.*;
public class t3 {
public t3() {
}
public static void main(String[] args) {
t3 t31 = new t3();
String driver = "oracle.jdbc.driver.OracleDriver";
String url = "jdbc:oracle:thin:@192.168.0.146:1521:ora8";
String uname = "scott";
String passwd = "tiger";
Connection conn = null;
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
conn = DriverManager.getConnection(url,uname,passwd);
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
}
环境变量配置如下:
.;D:bj183OracleDrvclasses12.zip;D:bj183OracleDrvnls_charset12.zip
总报错,如下:
java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
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:297)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:286)
at java.lang.ClassLoader.loadClass(ClassLoader.java:253)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:313)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:120)
at t1.t3.main(t3.java:29)
请高手指点迷津!谢谢!
开发工具:jbuilder5
数据库:oracle8.1.7
代码如下:
import java.sql.*;
public class t3 {
public t3() {
}
public static void main(String[] args) {
t3 t31 = new t3();
String driver = "oracle.jdbc.driver.OracleDriver";
String url = "jdbc:oracle:thin:@192.168.0.146:1521:ora8";
String uname = "scott";
String passwd = "tiger";
Connection conn = null;
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
conn = DriverManager.getConnection(url,uname,passwd);
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
}
环境变量配置如下:
.;D:bj183OracleDrvclasses12.zip;D:bj183OracleDrvnls_charset12.zip
总报错,如下:
java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
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:297)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:286)
at java.lang.ClassLoader.loadClass(ClassLoader.java:253)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:313)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:120)
at t1.t3.main(t3.java:29)
请高手指点迷津!谢谢!
|
jsp连接Oracle8/8i/9i数据库(用thin模式)
testoracle.jsp如下:
testoracle.jsp如下: