Scusate tutttttti
![]()
codice:public class Conn { private String utente; private String pass; private String indir; private ResultSet rst; private ResultSetMetaData rstM; private Statement cmd; private Connection con; private int nrorows; String error; String PATH =System.getenv("USERPROFILE")+"\\Manutenzione.log" ; PrintWriter print_line ; /*costruttore di defoult * */ public Conn(String ut,String pwd,String ind) { this.utente=ut; this.pass=pwd; this.indir=ind; try{ // scrivo sil log del programma eventuali errori di connessione FileWriter write = new FileWriter(PATH); print_line = new PrintWriter(write); print_line.printf("denis"); String driver = "sun.jdbc.odbc.JdbcOdbcDriver"; Class.forName(driver); String url = "jdbc:odbc:" + ind; con = DriverManager.getConnection(url, utente, pass); con.setAutoCommit(false); } catch (SQLException e){ print_line.printf(e.getMessage()); e.printStackTrace(); } catch (ClassNotFoundException e){ print_line.printf(e.getMessage()); e.printStackTrace(); } catch(IOException e){print_line.printf(e.getMessage());} } public void conn_On( String qry) { try{ int ret=0; cmd = con.createStatement(rst.TYPE_SCROLL_INSENSITIVE, rst.CONCUR_READ_ONLY); rst = cmd.executeQuery(qry); rstM= rst.getMetaData(); while (rst.next()) { ret = rst.getRow();} this.nrorows=ret; rst.beforeFirst(); //rst.first(); } catch (SQLException e){ e.printStackTrace(); } }

Rispondi quotando