File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java.sql.SQLException: [Oracle][ODBC][Ora]ORA-01017: invalid username/password; logon denied

 
lalit khera
Ranch Hand
Posts: 36
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please a look at this code, i am getting the error.

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;

public class InsertRecord {

public static void main(String[] args) {

String driver="sun.jdbc.odbc.JdbcOdbcDriver";
String cs="jdbcdbc:siva";
String user = "siva";
String pwd = "siva";
String sqlstmt="INSERT INTO employee VALUES(1,'Steve',5,70)";
Connection con = null;
Statement st = null;
try
{
Class.forName(driver);
}
catch(Exception e)
{
System.out.println(e);
}
System.out.println("Driver loaded");
try
{
con=DriverManager.getConnection(cs,user,pwd);
System.out.println("Connected to the Oracle Database");
st = con.createStatement();//creates a Statement object for sending SQL statements to the database.
int updatecount=st.executeUpdate(sqlstmt);//return either the row count for INSERT, UPDATE or DELETE statements, or 0 for SQL statements that return nothing
System.out.println(updatecount+" row inserted");
}
catch(Exception e)
{
System.out.println(e);
}
try
{
st.close();
con.close();
}
catch(Exception e)
{
System.out.println(e);
}
}//main()
}//class()



output is like:

Driver loaded
java.sql.SQLException: [Oracle][ODBC][Ora]ORA-01017: invalid username/password; logon denied
java.lang.NullPointerException


I am 100% sure that my username and password are siva and siva resp.
please help
 
Martin Vajsar
Sheriff
Pie
Posts: 3747
62
Chrome Netbeans IDE Oracle
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't use ODBC, if you're connecting to Oracle database. Use Oracle's type 4 JDBC driver (this page has a word or two on Oracle's drivers).

Can you verify using sqlplus that the password and username is correct? If you can, it is possible that the ODBC data source actually points to another database that you think it does.
 
lalit khera
Ranch Hand
Posts: 36
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Martin Vajsar wrote:Don't use ODBC, if you're connecting to Oracle database. Use Oracle's type 4 JDBC driver (this page has a word or two on Oracle's drivers).

Can you verify using sqlplus that the password and username is correct? If you can, it is possible that the ODBC data source actually points to another database that you think it does.


Hi martin , that problem was resolved.
Actually i have used sql developer for creating and maintaining my database named siva.
I have also used the same name for connection name, username, password.
But strangely the user siva that i have created using sql developer is not reflecting in the Oracle EM.
I dont know why, but once i re-create the user and the schema using Oracle EM, everything becomes fine.
Could you help me by providing few good links/tutorials where i can learn these oracle jdbc issues.
Do i need to use commit for reflecting the username that i have created using SQL developer to the oracle EM??

thnks
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic