java.sql.SQLException: General error

23,622

I get it.

The error is thrown due to the use of datatype timestamp(6) in update_time.The exception is thrown whenever we try to execute the select statement containing a column with timestamp as the datatype.

Instead of the previous code we can use the following code for selecting

    query="select latitude,longitude,to_char(update_time,'HH24:MI:SS'),to_char(update,time,'DD-MON-YY') from user_location_table";    

This works fine,I have tested it.

Cheers!!

Share:
23,622
Touchstone
Author by

Touchstone

Updated on October 31, 2020

Comments

  • Touchstone
    Touchstone over 3 years

    Getting java.sql.SQLException

    java.sql.SQLException: General error
    at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6986)
    at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7114)
    at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(JdbcOdbc.java:3110)
    at sun.jdbc.odbc.JdbcOdbcStatement.execute(JdbcOdbcStatement.java:338)
    at sun.jdbc.odbc.JdbcOdbcStatement.executeQuery(JdbcOdbcStatement.java:253)
    at com.test.Temp.main(Temp.java:29)
    

    I am using following code

    Connection con=null;
    ResultSet rs=null;
    Statement stmt=null;
    
    try {
      Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
      con=DriverManager.getConnection("jdbc:odbc:locator","locator","locator");
    
      stmt=con.createStatement();
      System.out.println("Before query");
      String query=null;
      query="select * from user_location_table";
      System.out.println("after query12");
    
      rs=stmt.executeQuery(query);
      //perform certain operation....
      rs.close();
      stmt.close();
      con.close();
    } catch(Exception e) {
      e.printStackTrace();
    }
    

    The exception is thrown at stmt.executeQuery(query).

    user_location_table contains following fields

    user_id:number  not null,
    latitude:number,
    longitude:number,
    update_time:timestamp(6)
    

    Thanks in advance