java连接oracle9.2.0.1.0 ( 积分: 20 )

  • 主题发起人 主题发起人 cbq16
  • 开始时间 开始时间
C

cbq16

Unregistered / Unconfirmed
GUEST, unregistred user!
我用eclipse编程环境连接oracle9.2.0.1.0,我的java源代码如下:
import java.sql.*;
public class ConOra {
public static void main(String arg[])
{
try
{
Class.forName("oracle.jdbc.Driver.OracleDriver").newInstance();
String url="jdbc:oracle:thin:@10.24.4.205:1521:ora9i";
String user="yz";
String password="yzyz";
Connection conn = DriverManager.getConnection(url,user,password);
Statement stmt=conn.createStatement();
String qstr="select * from tj_zjb";
ResultSet rs=stmt.executeQuery(qstr);
while (rs.next())
{
String tname=rs.getString("gdm");
System.out.println(tname);
}
rs.close();
stmt.close();
conn.close();
}
catch(SQLException sqle)
{
System.out.println(sqle.getMessage());
System.out.println(sqle.getSQLState());
}
catch(Exception e)
{
e.printStackTrace();
}
};
}
环境变量如下配置:
classpath=.
path=C:/Program Files/Java/jdk1.5.0_03/bin;C:/oracle/ora92/bin;C:/Program Files/Oracle/jre/1.3.1/bin;C:/Program Files/Oracle/jre/1.1.8/bin;%SystemRoot%/system32;%SystemRoot%;%SystemRoot%/System32/Wbem
我在编译这个文件时没有抱错,我在执行这个文件时java cbq.conoracle出现如下错误:
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:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:164)
at cbq.conoracle.main(conoracle.java:14)
请问我怎么确定1521的端口号。在线等待!!!谢谢。
 
我用eclipse编程环境连接oracle9.2.0.1.0,我的java源代码如下:
import java.sql.*;
public class ConOra {
public static void main(String arg[])
{
try
{
Class.forName("oracle.jdbc.Driver.OracleDriver").newInstance();
String url="jdbc:oracle:thin:@10.24.4.205:1521:ora9i";
String user="yz";
String password="yzyz";
Connection conn = DriverManager.getConnection(url,user,password);
Statement stmt=conn.createStatement();
String qstr="select * from tj_zjb";
ResultSet rs=stmt.executeQuery(qstr);
while (rs.next())
{
String tname=rs.getString("gdm");
System.out.println(tname);
}
rs.close();
stmt.close();
conn.close();
}
catch(SQLException sqle)
{
System.out.println(sqle.getMessage());
System.out.println(sqle.getSQLState());
}
catch(Exception e)
{
e.printStackTrace();
}
};
}
环境变量如下配置:
classpath=.
path=C:/Program Files/Java/jdk1.5.0_03/bin;C:/oracle/ora92/bin;C:/Program Files/Oracle/jre/1.3.1/bin;C:/Program Files/Oracle/jre/1.1.8/bin;%SystemRoot%/system32;%SystemRoot%;%SystemRoot%/System32/Wbem
我在编译这个文件时没有抱错,我在执行这个文件时java cbq.conoracle出现如下错误:
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:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:164)
at cbq.conoracle.main(conoracle.java:14)
请问我怎么确定1521的端口号。在线等待!!!谢谢。
 
问题已解决。
 
驱动程序放置不正确,在ECILIPSE里ADD library添加驱动
 

Similar threads

I
回复
0
查看
3K
import
I
I
回复
0
查看
2K
import
I
I
回复
0
查看
3K
import
I
I
回复
0
查看
3K
import
I
后退
顶部