JDBC Connection problem
I wrote a class to connect to an ORACLE database to select employer names.
The proper drivers gets loaded but when the connection is made, I get an "array out of bounds" error message.
Here is part of the code:
import java.sql.*;
=========================================================
/**
*
* @author Phlip Pretorius
*/
public class getEmplName
{
/** Creates a new instance of getEmplName */
public getEmplName()
{
} //end getEmplName
/* C:\oraclexe\app\oracle\product\10.2.0\server\jdbc\lib\ojdbc14_g.jar
* jdbc:oracle:thin:@127.0.0.1:1521:XE
* oracle.jdbc.driver.OracleDriver
*/
public static void main(String args[])
{
//String url = "jdbc:oracle:thin:@127.0.0.1:1521:XE";
String url = "jdbc:oracle:thin:@127.0.0.1:1521:XE";
System.out.println("1xxx Dis voor Connection con = null");
Connection con = null;
try
{
System.out.println("2xxx Dis voor String driver = oracle.jdbc.driver.OracleDriver");
String driver = "oracle.jdbc.driver.OracleDriver";
System.out.println("3xxx Dis voor Class.forName(driver).newInstance()");
Class.forName(driver).newInstance();
} // end try
catch( Exception e )
{
System.out.println("Failed to load Oracle driver.");
return;
} //end catch
try
{
System.out.println("4xxx Dis voor con = DriverManager.getConnection(url, hr, hr)");
con = DriverManager.getConnection(url,"hr","hr");
System.out.println("5xxx Dis voor Statement select = con.createStatement()");
Statement select = con.createStatement();
ResultSet result = select.executeQuery
("SELECT * FROM HR.EMPLOYEES order by EMPLOYEE_ID");
=========================================================
The program getrs executed up to the point 4xxx but then get the error message
1xxx Dis voor Connection con = null
2xxx Dis voor String driver = oracle.jdbc.driver.OracleDriver
3xxx Dis voor Class.forName(driver).newInstance()
4xxx Dis voor con = DriverManager.getConnection(url, hr, hr)
java.lang.ArrayIndexOutOfBoundsException: 7
at oracle.security.o3logon.C1.r(C1)
at oracle.security.o3logon.C1.l(C1)
at oracle.security.o3logon.C0.c(C0)
at oracle.security.o3logon.O3LoginClientHelper.getEPasswd(O3LoginClientHelper)
at oracle.jdbc.ttc7.O3log.<init>(O3log.java:290)
at oracle.jdbc.ttc7.TTC7Protocol.logon(TTC7Protocol.java:251)
at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:252)
at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java:365)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:260)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at getEmplName.main(getEmplName.java:51)
=========================================================
I wll appreciate any help that can resolve this issue.
Thanks in advance
Phlip

