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/*
* This sample can be used to check the JDBC installation.
* Just run it and provide the connect information. It will select
* "Hello World" from the database.
*/
// You need to import the java.sql package to use JDBC
import java.sql.*;
// We import java.io to be able to read from the command line
import java.io.*;
class JdbcCheckup
{
public static void main
(String args
[]) {
// Load the Oracle JDBC driver
DriverManager.
registerDriver(new oracle.
jdbc.
driver.
OracleDriver());
// Prompt the user for connect information
System.
out.
println("Please enter information to test connection to the database");
user = "root";
password = "gogogo";
database = "tiendax";
System.
out.
print("Connecting to the database...");
System.
out.
println("Connecting..."); ("jdbc:oracle:oci8:@" + database, user, password);
System.
out.
println("connected.");
// Create a statement
// Do the SQL "Hello World" thing
ResultSet rset
= stmt.
executeQuery("select 'Hello World' from dual");
while (rset.next())
System.
out.
println(rset.
getString(1)); // close the result set, the statement and connect
rset.close();
stmt.close();
conn.close();
System.
out.
println("Your JDBC installation is correct."); }
// Utility function to read a line from standard input
{
try
{
while (c != '\n' && c != -1)
{
buffer.append((char)c);
}
return buffer.toString().trim();
}
{
return "";
}
}
}
Y compilo usando este batch:
Código BASH:
Ver original@ECHO OFF
cd %~dp1
ECHO Compiling %~nx1...
IF EXIST %~n1.class (
DEL %~n1.class
)
javac -Xlint:unchecked %~nx1
IF EXIST %~n1.class (
ECHO Running %~n1...
java -classpath .;"C:\Program Files\Java\mysql-connectorJ\mysql-connector-java-3.0.17-ga-bin.jar" -ea %~n1
)
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!