during the execution of the my application java (developed following design pattern as front controller, dao factory, business object, singleton) i have a problem of connection at this line : Statement st = connessione.createStatement(ResultSet.TYPE_SCROLL_ INSENSITIVE, ResultSet.CONCUR_READ_ONLY); I using the rdbms mysql this problem is presented when I do much query on my db. This is my class that handle the connection with my database.
public class SQLDAOFactory extends DAOFactory implements AgroludosDAO { private static final String dbPath="jdbc:mysql://localhost/agroludos"; private static final String dbUser="root"; private static final String dbPass="root"; private SQLDAOFactory SQLFactory; public static Connection connectDB() { Connection connessione = null; // Caricamento del driver try { System.out.println("Caricamento Database. Attendere..."); connessione = DriverManager.getConnection(dbPath, dbUser, dbPass); System.out.println("Connessione OK"); } catch (SQLException e) { JPane.setError(JPane.WARNING_CONNECTION_DATABASE); JPane.getError(); } return connessione; }
and this is a code that realize my query:
try { //Crea uno statement per l'interrogazione del database Statement st = connessione.createStatement( ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); //Trace System.out.println("Database -> Interrogazione SQL: " + query); //Crea un ResultSet eseguendo l'interrogazione desiderata ResultSet tabellina = st.executeQuery(query); //Trace System.out.println("query ok"); return new TableModelCustom(tabellina); } catch (SQLException e) { e.printStackTrace(); return null; } }
How to resolve this problem? it is urgent!