Table connect
Friends:
My excuses, my English is bad
I'm using Apache, MySQL, Tomcat and PHP.
I connect myself to the data base with Java servlet. This connection is ACCEPTABLE, but when desire to make a question (query), the ResultSet is not found and sent a message with a java.lang.NullPointerException.
I sent a code fraction
************************************************************
public ConsultaObs( String u ) {
url= u;
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection con = DriverManager.getConnection(url, "user", "pass");
if (con != null)
{
Fechahoy hoy = new Fechahoy();
String p =hoy.fecha();
String p1=hoy.hora();
Texto texto = new Texto();
texto.Linea1(p,p1,"Apertura OK",url);
}
}catch ( java.lang.Exception ex ) {
try
{
Fechahoy hoy = new Fechahoy();
String p =hoy.fecha();
String p1=hoy.hora();
String error=ex.getMessage();
Texto texto = new Texto();
texto.Linea1(p,p1,"Error abriendo Base de Datos",url+" "+ex);
}catch(IOException e)
{}
}
}
*************************************************************
The query:
public ResultSet consultar( String query )
{
try {
if (con == null)
{
System.out.println(" Conexión a base de datos " + url + " Fallo sj");
}
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(query);
}catch ( SQLException ex ) {
System.out.println(ex.getMessage());
try
{Fechahoy hoy = new Fechahoy();
String p =hoy.fecha();
String p1=hoy.hora();
String error=ex.getMessage();
Texto texto = new Texto();
texto.Linea1(p,p1,"SQL"+error,query);
}catch(IOException e)
{}
}catch ( java.lang.Exception ex ) {
ex.printStackTrace ();
try
{Fechahoy hoy = new Fechahoy();
String p =hoy.fecha();
String p1=hoy.hora();
String error=ex.getLocalizedMessage();
Texto texto = new Texto();
texto.Linea1(p,p1,"Ejecutando Consulta", rs+" "+query+" "+ex);
}catch(IOException e)
{}
}
return rs;
}
If I consult it with phpmyadmin, I see all tables and your content.
Can you help me?
Eduardo Bieñkowski