5 Replies Latest reply on Oct 3, 2009 8:26 PM by jschellSomeoneStoleMyAlias

    javaw.exe - Application Error with JDBC

    843859

      Hello, I really need someone to help me identifying the following error
      The code that I'm using is the following:

      import java.sql.*; public class TestDBOracle { public static void main(String[] args) throws ClassNotFoundException, SQLException{ String url = "jdbc:odbc:oracle"; String user = "system"; String pass = "system"; Connection conn = DriverManager.getConnection(url, user, pass); conn.setAutoCommit(false); Statement stmt = conn.createStatement(); ResultSet rset = stmt.executeQuery("select * from emp"); while(rset.next()){ System.out.println(rset.getString(1)); } } }

      The driver of oracle has been added
      The connection to the database has been established

      I'm new to JDBC, I'm just running this code to see if it prints the query results properly
      but when I run it, the program terminates and the following error is showing up to me

      javaw.exe - Application Error
      The instruction at "0x7c910a19" referenced memory at "0xffffffff", The memory could not be "read".
      Click on OK to terminate the program

      Could anyone please tell what this error means and how to solve it?

      Edited by: Big_Java_007 on Oct 2, 2009 2:47 AM

        • 1. Re: javaw.exe - Application Error with JDBC
          843859
          You are trying to build an application which connect to oracle database and fetch data great. But which machine host the data?
          If you are using odbc, are you sure this is the right setting?
          • 2. Re: javaw.exe - Application Error with JDBC
            843859
            I never saw that error before, However, I suspect your connection string:
            String url = "jdbc:odbc:oracle"; isn't correct. I think it should be something roughly like jdbc:oracle:thin:@myDatabase:1520
            • 3. Re: javaw.exe - Application Error with JDBC
              jschellSomeoneStoleMyAlias
              Big_Java_007 wrote:
              javaw.exe - Application Error
              You can start by using "java" instead and also by catching all the exceptions and printing the stack trace.
              • 4. Re: javaw.exe - Application Error with JDBC
                843859
                Ok guys, I tried to change the connection string but it doesn't work
                and it produces an exception.
                Let me explain more.

                I have Oracle Database 10g Express Edition
                I went to Control Panel -> Administrative Tools -> Data Sources(ODBC)
                I found two types of drivers for oracle to add
                the first one is called Microsoft ODBC for oracle
                the second one is called Oracle in XE
                Actually I don't know the difference between them

                I used the first one ODBC for oracle
                the java program has succeded in establishing connection with oracle database
                and I could retrieve query results
                the connection string was
                String url = "jdbc:odbc:oracle"
                in fact I want to use the other format of the connection string that specifies the host where
                the database is stored, but it gives me an exception and the program terminates
                String url = "jdbc:oracle:thin:@127.0.0.1:1521:xe";
                The produced exception is:
                java.sql.SQLException: No suitable driver found for jdbc:oracle:thin:@127.0.0.1:1521:xe
                     at java.sql.DriverManager.getConnection(Unknown Source)
                     at java.sql.DriverManager.getConnection(Unknown Source)
                     at TestDBOracle.main(TestDBOracle.java:11)

                I'm really sure that the parts of the communication string are correct

                Even when I added the other driver which is Oracle in XE
                it didn't work also
                • 5. Re: javaw.exe - Application Error with JDBC
                  jschellSomeoneStoleMyAlias
                  You are not loading the driver.

                  You load the driver and then use the correct connect string for the driver.

                  The following is an example of doing that. You would modify it to use a different driver.

                  [http://java.sun.com/docs/books/tutorial/jdbc/basics/connecting.html]