import java.sql.*;public class Oracle_connection
{
public Oracle_connection()
{
}
public static void main(String[] args)
{
try
{
try
{
Class.forName("oracle.jdbc.OracleDriver");
System.out.println("找到驱动!");
}
catch(java.lang.ClassNotFoundException e)
{
System.err.print(e.getMessage());
}
String url="jdbc:oracle.thin:172.127.10.75:1521:compiere";
Connection conn=DriverManager.getConnection(url,"comp","");
System.out.println("驱动连接成功!");
Statement stmt=conn.createStatement();
ResultSet rs=stmt.executeQuery("select * from C_CHARGE");
while(rs.next())
{
System.out.println(rs.getString(1));
}
conn.close();
}
catch(SQLException ex)
{
while(ex!=null)
{
System.out.println(ex.getSQLState());
}
}
}
}
运行结果是:
找到驱动
08001
08001后面都是08001我不知道为什么?那位朋友知道吗?请说说.我是直接从我们公司内部网copy了个oracle.jar,也没装oracle的客户端软件.是不是非要装oracle的客户端软件才可以,我没用过oracle 的jdbc多多指教
{
public Oracle_connection()
{
}
public static void main(String[] args)
{
try
{
try
{
Class.forName("oracle.jdbc.OracleDriver");
System.out.println("找到驱动!");
}
catch(java.lang.ClassNotFoundException e)
{
System.err.print(e.getMessage());
}
String url="jdbc:oracle.thin:172.127.10.75:1521:compiere";
Connection conn=DriverManager.getConnection(url,"comp","");
System.out.println("驱动连接成功!");
Statement stmt=conn.createStatement();
ResultSet rs=stmt.executeQuery("select * from C_CHARGE");
while(rs.next())
{
System.out.println(rs.getString(1));
}
conn.close();
}
catch(SQLException ex)
{
while(ex!=null)
{
System.out.println(ex.getSQLState());
}
}
}
}
运行结果是:
找到驱动
08001
08001后面都是08001我不知道为什么?那位朋友知道吗?请说说.我是直接从我们公司内部网copy了个oracle.jar,也没装oracle的客户端软件.是不是非要装oracle的客户端软件才可以,我没用过oracle 的jdbc多多指教
现在出现了:
找到驱动
null
null
null
null
null
.
.
.
一直都这样害的我只能关掉窗口.
String url="jdbc:oracle.thin:172.127.10.75:1521:compiere";
数据库驱动写错了吧:oracle.jdbc.driver.OracleDriver
URL也写错了吧:jdbc:oracle.thin:@172.127.10.75:1521:compiere
这样写也不会出错么?
在你的catch中输出异常信息,
看看是什么信息?然后在查原因!
试试