Criei uma classe para receber os meus valores de tela e atualizar uma base de dados acess, mas esta ocorrendo o seguinte erro:
[color=red] -------CLASSE -----[/color]import [color=green[color=green]][color=darkred]java.sql.BatchUpdateException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
public class CriaRegistros {
[color=red][color=darkred]/** parametros de tela */[/color][/color]
public void atualizaBase(String cod,
String nome,
String email,
String fone){
//PrepareStatement ps = null;
String url = "jdbc:odbc:dbsample";
Connection con;
Statement stmt;
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}catch (ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.print(e.getMessage());
}
try{
con = DriverManager.getConnection(url, "user", "password");
con.setAutoCommit(false);
stmt = con.createStatement();
String query = "INSERT INTO Funcionario" + " VALUES(" + cod + ", " + nome + ", " + email + ", " + fone + ")";
//stmt.addBatch(query);
stmt.executeUpdate(query);
con.commit();
con.setAutoCommit(true);
stmt.close();
con.close();
} catch(BatchUpdateException b){
System.err.println("----- BatchUpdateException ---- ");
System.err.println("SQLState: " + b.getSQLState());
System.err.println("Message : " + b.getMessage());
System.err.println("Vendor : " + b.getErrorCode());
System.err.print("Update counts : ");
int [] updateCounts = b.getUpdateCounts();
for (int i = 0; i < updateCounts.length; i++ ){
System.err.print(updateCounts[i] + " ");
}
System.err.println(" ");
} catch(SQLException ex){
System.err.println("----- SQLException ---- ");
System.err.println("SQLState: " + ex.getSQLState());
System.err.println("Message : " + ex.getMessage());
System.err.println("Vendor : " + ex.getErrorCode());
}
}
}[/color][/color][/color]
[color=red][color=orange]
Erro retorna do console do eclipse[/color][/color]
[color=orange]----- SQLException ----
SQLState: 37000
Message : [Microsoft][Driver ODBC para Microsoft Access] Erro de sintaxe (operador faltando) na expressão de consulta ‘Carlos valentini’.
Vendor : -3100[/color]
