ciao...
ho risolto l'errore semplicemente aggiornando il drive....adesso però ho un altro errore
Codice PHP:
java.sql.SQLException
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:926)
at com.mysql.jdbc.ResultSetImpl.checkRowPos(ResultSetImpl.java:815)
at com.mysql.jdbc.ResultSetImpl.getObject(ResultSetImpl.java:4725)
at com.mysql.jdbc.ResultSetImpl.getObject(ResultSetImpl.java:4951)
at org.apache.tomcat.dbcp.dbcp.DelegatingResultSet.getObject(DelegatingResultSet.java:290)
at org.apache.jsp.pp_jsp._jspService(pp_jsp.java:89)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
di seguito il codice
Codice PHP:
%
try {
Class.forName("com.mysql.jdbc.Driver");
Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
DataSource ds = (DataSource) envCtx.lookup("jdbc/webappsDB");
Connection dbconn = ds.getConnection();
Statement statement=dbconn.createStatement();
String SQL = "SELECT count(*) as n FROM aa ";
ResultSet risultato=statement.executeQuery(SQL);
System.out.println( "n righe " + risultato.getRow());
int n= risultato.getInt("n");
dbconn.close();
} catch (SQLException e) {
e.printStackTrace();
System.out.println("SQLException: " + e.getMessage());
}
la print del getMessagge è null,se metto una tabella che non esiste nella select da un errore coerente avvertendo che la tabella non esiste ,quindi sembrerebbe che il db lo vede...
La count mi aspettavo che tornasse sempre un risultato ma invece getRow() è sempre zero..anche se levo la count e faccio la query su una delle colonne non tira fuori il risultato..eppure in tabella ci sono 2 righe.
Va in errore quando richiamo .getInt("n").
Qualcuno a qualche idea?
Grazie
Maurizio