como lo apaqueto?
Este es mi codigo:
/*Tendria q poner esto? */
Package Conexion
Este es mi codigo:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class cnxMySql {
/**
* @param args
*/
public void Conexion(){
Connection con=null;
Statement stmt=null;
ResultSet rs=null;
try{
String usr = "root";
String password = "tito";
//String driver = "oracle.jdbc.driver.OracleDriver";
String driver = "MyODBC-3.51.11-2-win.exe";
String url = "jdbc:mysql://
[email protected]";
Class.forName(driver);
con = DriverManager.getConnection(url,usr,password );
stmt=con.createStatement();
rs=stmt.executeQuery("SELECT nombre FROM Usuarios WHERE usrHosp ='HGUGM'");
while (rs.next()){
System.out.println(rs.getString("nombre"));
}
}catch (ClassNotFoundException e){
System.out.println("No se pudo cargar el driver "+e.getMessage());
}catch(SQLException e){
System.out.println("SQLException atrapada "+e.getMessage());
}
finally{
try{
if (con!=null) con.close();
}
catch(SQLException ignorado){}
}
}
public static void main(String[] args) throws InterruptedException {
// TODO Auto-generated method stub
System.out.println("Comienza Main...");
cnxMySql con=new cnxMySql();
con.Conexion();
}
}