1 Reply Latest reply: Jul 29, 2013 2:21 AM by brunors RSS

    Connection to Database Error

    e315dff1-8826-450c-aa07-73d121ca8bdd

      I am using Oracle Express Edition to work with a project. I have the following code to connect to my database:

       

       

        public static void main(String[] args) {
      
              try {
                  Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                  Connection con = DriverManager.getConnection("jdbc:oracle:driver_type:[username/password]@//host_name:port_number:SID");
                  Statement st = con.createStatement();
                  ResultSet rs = st.executeQuery("Select * from [Sheet1$]");
      
                  ResultSetMetaData rsmd = rs.getMetaData();
                  int numberOfColumns = rsmd.getColumnCount();
                  
                  
                  while (rs.next()) {
      
                      for (int i = 1; i <= numberOfColumns; i++) {
                          if (i > 1)
                              System.out.print(", ");
                          String columnValue = rs.getString(i);
                          System.out.print(columnValue);
                      }
                      System.out.println("");
                  }
      
                  st.close();
                  con.close();
      
              } catch (Exception ex) {
                  System.err.print("Exception: ");
                  System.err.println(ex.getMessage());
              }
              
             
              
          }
      

       

       

      When I try to run it, I get a failed to call database error, Missing in or out parameter at index 1. What is wrong with my code? Any help would be appreciated.