Ich versuche, Daten in meine Postgresql -Datenbank einzufügen, aber wenn ich die methode executeUpdate () ausführe, fügt sie keine Daten zu meinem dB ein, und ich kann nicht sehen, wo ich falsch mache ... < /p>
PS: Meine Datenbank ist autokommit: on; < /p>
jdbc:postgresql://dataBaseAddress/dataBaseName
org.postgresql
2
20
user
password
org.postgresql.xa.PGXADataSource
org.h2.jdbcx.JdbcDataSource
< /code>
Hier ist meine Verbindungsklasse: < /p>
public Connection getConnection() throws TopLevelException, SQLException {
Connection conn = null;
try {
Context ctx = new InitialContext();
TransactionBean tal = (TransactionBean) ctx.lookup("java:global/snrng-ear/snrng-ejb-lgc/TransactionBean!br.com.compplied.snrng.ejb.TransactionBean");
conn = tal.getConnection();
} catch (NamingException e) {
throw new TopLevelException(e);
}
return conn;
}
< /code>
Hier ist die Methode, mit der mein Einfügen < /p>
ausgeführt wirdpublic int inserirHistorico(RetornoHistoricoObject retorno) throws TopLevelException {
int update = 0;
PreparedStatement ps = null;
ResultSet rs = null;
Connection con = null;
String sql = "INSERT INTO table ( column1, column2, column3, column4, column5, column6) values (?, ?, ?, ?, ?, localtimestamp)";
try {
con = getConnection();
ps = con.prepareStatement(sql);
rs = ps.getResultSet();
ps.setString(1, retorno.getNome_arquivo());
ps.setString(2, retorno.getNumero_autenticacao().trim());
ps.setString(3, retorno.getNosso_numero());
ps.setDate(4, retorno.getData_pagamento());
ps.setDouble(5, retorno.getValor());
update = ps.executeUpdate();
} catch (SQLException e) {
throw new TopLevelException(e);
} catch (Exception e) {
throw new TopLevelException(e);
} finally {
try {
close(rs, ps, con);
} catch (SQLException e) {
throw new TopLevelException(e);
}
}
return update;
}
< /code>
Wenn ich die ps.executeUpdate () -Methode ausführe, wird mir eine Erfolgsnachricht mit der neuen ID zurückgegeben, aber wenn ich nach dieser ID in meiner Tabelle suche, wird dort nichts eingefügt. Ich habe bereits meinen DB -Parameter, meine Verbindung und so überprüft, aber es funktioniert immer noch nicht ... kann mir jemand helfen?
Mein ExecuteUpdate () arbeitet, aber nicht verpflichtet ⇐ Java
-
- Similar Topics
- Replies
- Views
- Last post
-
-
Mein Tooltip arbeitet nicht auf Android, da GetboundingClientRect 0 zurückkehrt
by Anonymous » » in CSS - 0 Replies
- 3 Views
-
Last post by Anonymous
-