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

Gente:

Buenas a todos...... estoy tratando de usar MySQL en Java y tengo la misma (mala) suerte que con C++ en mi sistema Windows


Al compilar me dice esto:

Cita:
Compiling JdbcCheckup.java...
JdbcCheckup.java:19: error: package oracle.jdbc.driver does not exist
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
El programa de prueba es ..

Código Java:
Ver original
  1. /*
  2.  * This sample can be used to check the JDBC installation.
  3.  * Just run it and provide the connect information.  It will select
  4.  * "Hello World" from the database.
  5.  */
  6.  
  7. // You need to import the java.sql package to use JDBC
  8. import java.sql.*;
  9.  
  10. // We import java.io to be able to read from the command line
  11. import java.io.*;
  12.  
  13. class JdbcCheckup
  14. {
  15.    public static void main(String args[])
  16.           throws SQLException, IOException
  17.    {
  18.       // Load the Oracle JDBC driver
  19.       DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
  20.  
  21.       // Prompt the user for connect information
  22.       System.out.println("Please enter information to test connection to the database");
  23.       String user;
  24.       String password;
  25.       String database;
  26.  
  27.       user = "root";
  28.       password = "gogogo";        
  29.       database = "tiendax";
  30.  
  31.       System.out.print("Connecting to the database...");
  32.       System.out.flush();
  33.  
  34.       System.out.println("Connecting...");
  35.       Connection conn = DriverManager.getConnection
  36.                         ("jdbc:oracle:oci8:@" + database, user, password);
  37.  
  38.       System.out.println("connected.");
  39.  
  40.       // Create a statement
  41.       Statement stmt = conn.createStatement();
  42.  
  43.       // Do the SQL "Hello World" thing
  44.       ResultSet rset = stmt.executeQuery("select 'Hello World' from dual");
  45.  
  46.       while (rset.next())
  47.          System.out.println(rset.getString(1));
  48.       // close the result set, the statement and connect
  49.       rset.close();
  50.       stmt.close();
  51.       conn.close();
  52.       System.out.println("Your JDBC installation is correct.");
  53.    }
  54.  
  55.    // Utility function to read a line from standard input
  56.    static String readEntry(String prompt)
  57.    {
  58.       try
  59.       {
  60.          StringBuffer buffer = new StringBuffer();
  61.          System.out.print(prompt);
  62.          System.out.flush();
  63.          int c = System.in.read();
  64.          while (c != '\n' && c != -1)
  65.          {
  66.             buffer.append((char)c);
  67.             c = System.in.read();
  68.          }
  69.          return buffer.toString().trim();
  70.       }
  71.       catch(IOException e)
  72.       {
  73.          return "";
  74.       }
  75.    }
  76. }


Y compilo usando este batch:

Código BASH:
Ver original
  1. @ECHO OFF
  2. cd %~dp1
  3. ECHO Compiling %~nx1...
  4. IF EXIST %~n1.class (
  5. DEL %~n1.class
  6. )
  7. javac -Xlint:unchecked %~nx1
  8. IF EXIST %~n1.class (
  9. ECHO Running %~n1...
  10. java -classpath .;"C:\Program Files\Java\mysql-connectorJ\mysql-connector-java-3.0.17-ga-bin.jar" -ea %~n1
  11. )

Tengo el archivo mysql-connector-java-3.0.17-ga-bin.jar en "C:\Program Files\Java\connectorJ-mysql"


Alguna idea ?

Mil gracias por su tiempo!
__________________
Salu2!