Results 1 to 10 of 10
  1. #1
    Join Date
    Dec 2003
    Posts
    3

    Unanswered: Problem with database connection

    hi, i have a problem, i'm using classes12.jar to connect to the oracle database. and i get this error
    "Error connecting: java.sql.SQLException: Io exception: Got minus one from a read call"
    i checked and every thing is allright(host,port,sid etc)
    but still.....

    the code is:

    String driver="oracle.jdbc.driver.OracleDriver";
    String host = "localhost";
    String dbName = "killaz";
    String url="jdbcracle:thin:@"+host+":1521:"+dbName;
    String username = "scott";
    String password ="tiger";
    Class.forName(driver);
    Connection connection = DriverManager.getConnection(url,username,password) ;

    help!

  2. #2
    Join Date
    Oct 2003
    Location
    Delhi, India
    Posts
    16

    Re: Problem with database connection

    seems everything ok but could u plz be more specific about ur problem and give more code where u r fetching records from the database as i think there must be some error in fetching data coz Every other thing is perfect otherwise

  3. #3
    Join Date
    Dec 2003
    Posts
    3

    Re: Problem with database connection

    Originally posted by deep_ar78
    seems everything ok but could u plz be more specific about ur problem and give more code where u r fetching records from the database as i think there must be some error in fetching data coz Every other thing is perfect otherwise

    I'm just want to see if my connection with database is working, so this is the code :

    public static void main(String[] args) {


    String driver="oracle.jdbc.driver.OracleDriver";
    String host = "localhost";
    String dbName = "killaz";
    //String url = DriverUtilities.makeURL(host, dbName, vendor);
    String url="jdbcracle:thin:@"+host+":1521:"+dbName;
    String username = "scott";
    String password ="tiger";
    showTable(driver, url, username, password);
    }

    public static void showTable(String driver,
    String url,
    String username,
    String password) {

    try {
    Class.forName(driver);
    Connection connection = DriverManager.getConnection(url,username,password) ;
    Statement statement = connection.createStatement();
    String query = "SELECT * FROM emp;";
    ResultSet resultSet = statement.executeQuery(query);

    while(resultSet.next()) {

    System.out.print(" " + resultSet.getInt(1));
    System.out.print(" " + resultSet.getString(2));
    System.out.print(" " + resultSet.getString(3));
    System.out.print(" " + resultSet.getInt(4));
    System.out.println(" " + resultSet.getInt(6));
    System.out.println(" " + resultSet.getInt(7));
    System.out.println(" " + resultSet.getInt(8));

    }
    } catch(ClassNotFoundException cnfe) {
    System.err.println("Error loading driver: " + cnfe);
    } catch(SQLException sqle) {
    System.err.println("Error connecting: " + sqle);
    }
    }

  4. #4
    Join Date
    Oct 2003
    Location
    Delhi, India
    Posts
    16

    Re: Problem with database connection

    well the code is working fine on my machine and i cant guess now whats going wrong on ur machine...i would just say include both classes111.jar and classes12.jar in apache_home/common/lib and let see wut happens
    Best of luck

  5. #5
    Join Date
    Dec 2003
    Posts
    3

    Re: Problem with database connection

    Originally posted by deep_ar78
    well the code is working fine on my machine and i cant guess now whats going wrong on ur machine...i would just say include both classes111.jar and classes12.jar in apache_home/common/lib and let see wut happens
    Best of luck
    ok, thank u. someone told me that it is a problem with my LAN settings.
    again, 10thx

  6. #6
    Join Date
    Dec 2003
    Location
    Netherlands
    Posts
    5

    Lightbulb

    Hello there.

    I have also the same problem with my SQL connection. The only difference between mine and Killaz is that I am using a Typical MySQL DB created in phpmyadmin and running on localhost.

    Any suggestions???

    Please reply here: http://www.dbforums.com/t974955.html



  7. #7
    Join Date
    Dec 2003
    Posts
    2

    Re: Problem with database connection

    Originally posted by deep_ar78
    well the code is working fine on my machine and i cant guess now whats going wrong on ur machine...i would just say include both classes111.jar and classes12.jar in apache_home/common/lib and let see wut happens
    Best of luck
    Hi, I just come across your reply to the message describing a similar problem I have connecting to Oracle9i DB. I tried a couple of simple java files (Including the one you discussed here) to check connection to my newly locally installed Oracle9i DB, and I have two types of errors depending on the driver I use. Since I am new to Oracle could you please tell me where the problem area? Do I have to put something else in the Classpath in addition to classes.12.zip to make it work?

    The errors I have:
    1. Error connecting: java.sql.SQLException: Invalid Oracle URL specified

    2. Exception in thread "main" java.sql.SQLException: Invalid Oracle URL specified
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBE rror.java:180)
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBE rror.java:222)
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBE rror.java:285)
    at oracle.jdbc.driver.OracleDriver.connect(OracleDriv er.java:203)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at RecordingOCI.main(RecordingOCI.java:8)

    Any suggestion would be higly appreciated.

    Thank you.

  8. #8
    Join Date
    Dec 2003
    Location
    Netherlands
    Posts
    5
    Can you post the URL that you've used to connect to the Oracle DB?

  9. #9
    Join Date
    Dec 2003
    Posts
    2
    Originally posted by elitearuba
    Can you post the URL that you've used to connect to the Oracle DB?
    I've used this
    ("jdbcracleci9:@(description=(address=(host=dbserver)(protoco l=tcp)(port=1521)) connect_data=(sid=database)))", "scott", "tiger");
    this
    "jdbcracle:thin:@trianon:1521:local", "scott", "tiger",
    and that
    ("jdbcracleci:@trianon", "scott", "tiger");

    Also, I tried the one in the posted sample and got the same URL error.

    trianon

  10. #10
    Join Date
    Dec 2004
    Posts
    1

    What problem with LAN settings?

    Quote Originally Posted by killaz
    ok, thank u. someone told me that it is a problem with my LAN settings.
    again, 10thx
    Hi Killaz, I am getting the same "minus one" problem with my JDBC call. Can you please elaborate what sort of problem with LAN settings you faced and how you resolved it?

    Thanks a lot.

    Raj

Posting Permissions

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