ojdbc14 jar 甲骨文 10g java java.lang.ClassNotFoundException
ojdbc14 jar oracle 10g java java.lang.ClassNotFoundException
大家好我遇到了以下错误
java.lang.ClassNotFoundException: oracle.jdbc.pool.OracleConnectionPoolDataSource
Exception in thread "main" Message: No suitable driver found for jdbc:odbc:10.43.210.170:1521:radem
java.lang.NullPointerException
at com.test.DBcnx.main(DBcnx.java:25)
我知道它以前发布过,我检查了答案..试图将驱动程序 (ojdbc14.jar) 放在与 class 相同的路径中,但仍然是相同的错误..我有点像java 业余所以基本上我不知道我在做什么或我应该做什么..我的代码如下:
package com.test;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class DBcnx {
//connection
static String url="jdbc:thin:oracle:10.43.210.170:1521:radem";
static String user="USER1";
static String pass="radem";
static String driver="oracle.jdbc.pool.OracleConnectionPoolDataSource";
static Connection con;
static boolean isconnect ;
public static void main(String args[] ) throws SQLException
{
isconnect=Connect(url,user,pass,driver);
String select = "select * from dual";
Statement stmt = con.createStatement();
ResultSet result = stmt.executeQuery(select);
while( result.next())
{
System.out.println(result.getString("TABLE_NAME"));
}
stmt.close();
}
public static boolean Connect(String url,String user,String pass, String driver)
{
try{
try{
Class.forName(driver);
System.out.println("chargement driver");
}catch(ClassNotFoundException e)
{
System.err.println("Chargement drivers echoue\n"+e);
}
con = DriverManager.getConnection(url,user,pass);
System.out.println("\nConnection a la base etablie");
}
catch(Exception evt)
{
System.out.println("Message: "+ evt.getMessage()); ;
return false;
}
return true;
}
}
欢迎任何帮助..谢谢!
您的驱动程序 class 名称不正确。应该是 oracle.jdbc.OracleDriver.
你return一个布尔标志来指示连接是否成功,但你忽略了它。
大家好我遇到了以下错误
java.lang.ClassNotFoundException: oracle.jdbc.pool.OracleConnectionPoolDataSource
Exception in thread "main" Message: No suitable driver found for jdbc:odbc:10.43.210.170:1521:radem
java.lang.NullPointerException
at com.test.DBcnx.main(DBcnx.java:25)
我知道它以前发布过,我检查了答案..试图将驱动程序 (ojdbc14.jar) 放在与 class 相同的路径中,但仍然是相同的错误..我有点像java 业余所以基本上我不知道我在做什么或我应该做什么..我的代码如下:
package com.test;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class DBcnx {
//connection
static String url="jdbc:thin:oracle:10.43.210.170:1521:radem";
static String user="USER1";
static String pass="radem";
static String driver="oracle.jdbc.pool.OracleConnectionPoolDataSource";
static Connection con;
static boolean isconnect ;
public static void main(String args[] ) throws SQLException
{
isconnect=Connect(url,user,pass,driver);
String select = "select * from dual";
Statement stmt = con.createStatement();
ResultSet result = stmt.executeQuery(select);
while( result.next())
{
System.out.println(result.getString("TABLE_NAME"));
}
stmt.close();
}
public static boolean Connect(String url,String user,String pass, String driver)
{
try{
try{
Class.forName(driver);
System.out.println("chargement driver");
}catch(ClassNotFoundException e)
{
System.err.println("Chargement drivers echoue\n"+e);
}
con = DriverManager.getConnection(url,user,pass);
System.out.println("\nConnection a la base etablie");
}
catch(Exception evt)
{
System.out.println("Message: "+ evt.getMessage()); ;
return false;
}
return true;
}
}
欢迎任何帮助..谢谢!
您的驱动程序 class 名称不正确。应该是 oracle.jdbc.OracleDriver.
你return一个布尔标志来指示连接是否成功,但你忽略了它。