Results 1 to 2 of 2
  1. #1
    OMFGITSROHIT is offline Member
    Join Date
    Mar 2010
    Posts
    23
    Rep Power
    0

    Default java.sql.SQLException: [Oracle][ODBC][Ora]ORA-00904: invalid column name

    errors-
    java.sql.SQLException: [Oracle][ODBC][Ora]ORA-00904: invalid column name
    at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc .java:6957)
    at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java :7114)
    at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(JdbcOdbc.java :3110)
    at sun.jdbc.odbc.JdbcOdbcStatement.execute(JdbcOdbcSt atement.java:338)
    at sun.jdbc.odbc.JdbcOdbcStatement.executeQuery(JdbcO dbcStatement.java:253)


    Java Code:
        private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {                                      
    String user= new String(jTextField1.getText());
    String pass= new String(jPasswordField1.getPassword());
    if(a<4)
    {
    Connection con = null;
    String driver="sun.jdbc.odbc.JdbcOdbcDriver";
    String user1 = "scott";
    String pass1 = "tiger";
    try{
    Class.forName(driver);
    con = DriverManager.getConnection("jdbc:odbc:login",user1,pass1);
    Statement s=con.createStatement();
    ResultSet password=s.executeQuery("Select pass from login where username="+user);
    if(pass.contentEquals(password.getString(1)))
    {
        a=0;
        JOptionPane.showMessageDialog(rootPane, "Access Granted");
        ResultSet access=s.executeQuery("Select access_power from login where username="+user);
        access_power=access.getString(1);
        new Exam_Season().setVisible(true);
        this.setVisible(false);
    }
    else
    {
        JOptionPane.showMessageDialog(rootPane, "Access Denied.");
        a++;
    }
    }
    catch(Exception e)
    {
    e.printStackTrace();
    JOptionPane.showMessageDialog(rootPane, "Connection not successful.");
    }
    }
    else
    {
        JOptionPane.showMessageDialog(rootPane, "Too many attempts.");
        System.exit(0); 
    }
    
        }
    Help please! I've created a separate dsn using odbc sources. And I'm trying to connect using jdbc odbc bridge. Doesn't work.

  2. #2
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    8

    Default

    Use PreparedStatement (see the API docs), and learn some SQL. That error is because you are not quoting (in the SQL context) the value being queried.

Similar Threads

  1. java.sql.SQLException: Closed Connection
    By sunjavaboy in forum JDBC
    Replies: 4
    Last Post: 03-21-2012, 01:38 PM
  2. java.sql.SQLException: ORA-01722: invalid number
    By balushanmukha in forum JDBC
    Replies: 0
    Last Post: 08-27-2008, 06:52 PM
  3. Replies: 0
    Last Post: 11-08-2007, 08:48 AM
  4. Replies: 1
    Last Post: 08-06-2007, 09:24 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •