Ver Mensaje Individual
  #3 (permalink)  
Antiguo 22/03/2007, 06:23
Melisa Noemi
 
Fecha de Ingreso: marzo-2007
Mensajes: 4
Antigüedad: 17 años, 2 meses
Puntos: 0
Re: Error al conectarme desde java a Mysql

public class Conexion
{
private static String login = "";
private static String password = "";
private static String url = "";
private static String driver = "";
private static Connection conn = null;

Conexion()
{
try
{
Properties p = new Properties();
p.load(new FileInputStream("config.ini"));
login = p.getProperty("login");
password = p.getProperty("password");
url = p.getProperty("url");
driver = p.getProperty("driver");

}
catch (Exception e)
{
System.out.println(e);
}

try
{
Class.forName(driver).newInstance();
Connection conn = DriverManager.getConnection(url,"root","");
System.out.println("creada la conexion");
}
catch(Exception e)
{
System.out.println(e);
}
}

58 public ArrayList cargar(String tabla)
59 {
60
61 ArrayList Espermogramas_des = new ArrayList();
62 Statement stmt;
63
64 try {
65 System.out.println(conn);
66 stmt = conn.createStatement();
67 System.out.println("hola133 ");
68
if (conn != null)
{
Esperma E;
int cont=0;
ResultSet rest;
rest= stmt.executeQuery("Select * from "+tabla);


while(rest.next())
{
E = new Esperma();
String aux = new String();
E.setFactura(rest.getInt("Factura"));
E.setVol(rest.getDouble("VOLUMEN"));
E.setConcen(rest.getDouble("CONCENTRACION"));
E.setPrpm(rest.getDouble("PR_PM"));
E.setInmoviles(rest.getDouble("PIV"));
E.setFormasnormales(rest.getDouble("FORMASNORMALES "));
E.setClasificacion(rest.getString("CLASIFICACION") );
E.setSeveridad(rest.getString("SEVERIDAD"));

Espermogramas_des.add(E);
cont++;
}

//System.out.println("La cantidad total de espermas qe hay en espermogramas son: " + cont);
stmt.close();
rest.close();
}

} catch (SQLException e)
{
e.printStackTrace();}
return Espermogramas_des;
}

Hola, como dije anteriormente la conexion si se crea pero como que no lee la base de datos porque el mensaje que dice conexion creada lo dice cuando lo corro.