ragazzi ho fatto questa semplice connessione al database per semplificare il tutto
nn mi aggiorna i record nella tabella del database access:
sapete aiutarmi?Codice PHP:import java.io.*;
import java.sql.*;
import java.util.*;
public class BuchUpdateExample {
public static void main(String[]args)throws ClassNotFoundException,SQLException,IOException
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con= null;
String connessione ="jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=";
try{
File file = new File("dati/over.mdb");
con = DriverManager.getConnection(connessione+file.getAbsolutePath());
Statement stmt = con.createStatement();
stmt.executeUpdate("DROP TABLE over90");
stmt.executeUpdate("CREATE TABLE over90" + " (" + "lastName VARCHAR(20)," + "firstName VARCHAR(20)," + "age INTEGER" + " )");
con.setAutoCommit(false);
stmt.clearBatch();
stmt.addBatch("INSERT INTO over90 VALUES" + "('Rodrigo1','Joaquin',96)");
stmt.addBatch("INSERT INTO over90 VALUES" + "('Rodrigo2','Joaquin',96)");
stmt.addBatch("INSERT INTO over90 VALUES" + "('Rodrigo3','Joaquin',93)");
int [] counts = stmt.executeBatch();
boolean allGood = true;
for(int i=0;i<counts.length;i++)
if(counts != null)
allGood=false;
if(allGood){
System.out.println("record aggiornati" + counts.length);
con.commit();
}else{
System.out.println("transazione fallita");
con.rollback();
}
stmt.close();
}finally{
if(con != null)
con.close();
}
}
}
p.s. la stringa di connessione è giusta solo ke quando la scrivo qui viene fuori img src = "ecc ecc

Rispondi quotando