Ver Mensaje Individual
  #2 (permalink)  
Antiguo 02/07/2014, 15:24
Avatar de Italico76
Italico76
 
Fecha de Ingreso: abril-2007
Mensajes: 3.303
Antigüedad: 17 años, 1 mes
Puntos: 292
Respuesta: JdbcCheckup.java: package oracle.jdbc.driver does not exist

Y para otra forma de conexion el error que obtengo es distinto pero nunca tengo exito:

Cita:
java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:8888/xxxxxxx
Código Java:
Ver original
  1. import java.sql.*;   // Use classes in java.sql package
  2.  
  3. // JDK 7 and above
  4. public class JdbcSelectTest {  // Save as "JdbcSelectTest.java"
  5.    public static void main(String[] args) {
  6.       try (
  7.          // Step 1: Allocate a database "Connection" object
  8.          Connection conn = DriverManager.getConnection(
  9.                "jdbc:mysql://localhost:8888/ebookshop", "myuser", "xxxx"); // MySQL
  10.  
  11.          // Step 2: Allocate a "Statement" object in the Connection
  12.          Statement stmt = conn.createStatement();
  13.       ) {
  14.          // Step 3: Execute a SQL SELECT query, the query result
  15.          //  is returned in a "ResultSet" object.
  16.          String strSelect = "select title, price, qty from books";
  17.          System.out.println("The SQL query is: " + strSelect); // Echo For debugging
  18.          System.out.println();
  19.  
  20.          ResultSet rset = stmt.executeQuery(strSelect);
  21.  
  22.          // Step 4: Process the ResultSet by scrolling the cursor forward via next().
  23.          //  For each row, retrieve the contents of the cells with getXxx(columnName).
  24.          System.out.println("The records selected are:");
  25.          int rowCount = 0;
  26.          while(rset.next()) {   // Move the cursor to the next row
  27.             String title = rset.getString("title");
  28.             double price = rset.getDouble("price");
  29.             int    qty   = rset.getInt("qty");
  30.             System.out.println(title + ", " + price + ", " + qty);
  31.             ++rowCount;
  32.          }
  33.          System.out.println("Total number of records = " + rowCount);
  34.  
  35.       } catch(SQLException ex) {
  36.          ex.printStackTrace();
  37.       }
  38.       // Step 5: Close the resources - Done automatically by try-with-resources
  39.    }
  40. }
__________________
Salu2!