Java in Linux connecting to Oracle - java.sql.SQLException: ORA-01017: inva
Hi Java Guru's,
After 8 years with micrsoft technologies its hard to move to something without a GUI and I I have a simple problem which I am not able to resolve.
I am basically totally new to java and linux. I did all my development on windows using eclipse and my application ran fine. It runs on windows without any issues but, when I move my code to a Linux box it just does not work. The applicaition does not even connect to the database.
For simplification I created a simple class which connects to the db and executes a sp that's it; plain and simple. This works fine from windows but, from linux I keep getting
"java.sql.SQLException: ORA-01017: invalid username/password; logon denied"
The username and password is correct and I have tried that with sqlplus in linux box. I think the problem is with some configuration
Here is my environment values:
HOSTNAME=XXXXXX
TERM=vt100
SHELL=/bin/bash
HISTSIZE=1000
SSH_CLIENT=XXX.XX.XX.XX 1792 22
QTDIR=/usr/lib64/qt-3.1
SSH_TTY=/dev/pts/0
USER=sagarwal
LD_LIBRARY_PATH=/dpd/u01/app/oracle/product/9.2/lib:/dpd/u01/app/oracle/product/9.2/jdbc/lib
LS_COLORS=no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=01;32:*.cmd=01;32:*.exe=01;32:*.com=01;32:*.btm=01;32:*.bat=01;32:*.sh=01;32:*.csh=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.bz=01;31:*.tz=01;31:*.rpm=01;31:*.cpio=01;31:*.jpg=01;35:*.gif=01;35:*.bmp=01;35:*.xbm=01;35:*.xpm=01;35:*.png=01;35:*.tif=01;35:
ORACLE_SID=dpd
MAIL=/var/spool/mail/sagarwal
PATH=/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/export1/home/nYDS/bin:/dpd/u01/app/oracle/product/9.2/bin:/dpd/u01/app/oracle/product/9.2/jdbc/lib:/dpd/u01/app/oracle/product/9.2/lib:/export1/home/nYDS/PAM/nyds/DBHelper
INPUTRC=/etc/inputrc
PWD=/export1/home/nYDS/PAM
LANG=en_US.UTF-8
LAMHELPFILE=/etc/lam/lam-helpfile
SSH_ASKPASS=/usr/libexec/openssh/gnome-ssh-askpass
SHLVL=1
HOME=/export1/home/nYDS
LOGNAME=sagarwal
CLASSPATH=/dpd/u01/app/oracle/product/9.2/jdbc/lib/classes12.jar:/dpd/u01/app/oracle/product/9.2/rdbms/jlib/xdb.jar:/dpd/u01/app/oracle/product/9.2/sqlj/lib/runtime12.jar:/dpd/u01/app/oracle/product/9.2/sqlj/lib/translator.jar:/dpd/u01/app/oracle/product/9.2/jdbc/lib/classes12_g.jar
SSH_CONNECTION=XXX.XX.XX.XX XXXX XXX.21.33.186 22
LESSOPEN=|/usr/bin/lesspipe.sh %s
ORACLE_HOME=/dpd/u01/app/oracle/product/9.2
G_BROKEN_FILENAMES=1
_=/bin/env
OLDPWD=/export1/home/nYDS/PAM/test
Here is my code
package test;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import oracle.jdbc.OracleTypes;
import oracle.jdbc.driver.OracleDriver;
import oracle.jdbc.pool.OracleDataSource;
import java.sql.*;
public class TestDA {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("started");
showData();
System.out.println("done");
}
public static Connection getConnection()
{
Connection conn = null;
Stringusername = "XXX";
Stringpassword = "XXX123";
Stringdriver_class = "oracle.jdbc.driver.OracleDriver";
StringthinConn= "jdbc:oracle:thin:@xxxxxx.co.xxxx.com:1521:xyz";
System.out.println("in getConnection");
if(conn != null)
return conn ;
try
{
System.out.print("Loading JDBC Driver -> " + driver_class + "\n");
Class.forName (driver_class).newInstance();
System.out.print("Connecting to-> " + thinConn + ", " + username + ", " + password + "\n");
conn = DriverManager.getConnection(thinConn, username, password);
return conn;
}
catch (Exception e)
{
e.printStackTrace();
// throw new SQLException("Error loading JDBC Driver");
}
return conn ;
}
public static void showData()
{
try
{
System.out.println("in showdata");
Connection conn = getConnection();
System.out.println("connection worked");
String sp_Query ;
sp_Query = "{call XXX.XXXXXXXX (?,?)}" ;
CallableStatement sp_stmnt = conn.prepareCall(sp_Query);
sp_stmnt.setString(1, "XXXXXXXX_XXXXXX_XXXXX");
sp_stmnt.registerOutParameter(2, OracleTypes.CURSOR);
System.out.println("calling execute");
int rcdsafctd = sp_stmnt.executeUpdate() ;
System.out.println(rcdsafctd);
ResultSet x = (ResultSet)sp_stmnt.getObject(2);
while(x.next())
{
System.out.println(x.getString(2));
}
}
catch(Exception err)
{
err.printStackTrace();
}
}
}
Please HELP !!!!!!!!!!!!!

