In Java ist alles einfach und direkt, wenn man weiss wie ;p

Darum zu meiner Erinnerung einmal komplett wie man ein Datenbank Update mit einem PreparedStatement macht

Hier aus einem JUnit Test, bei einer Oracle Datenbank (DataBaseQuerySchema)

@Test
public void TestUpdateSiebenZwerge() {

double result = 0.0;

String sql = "INSERT INTO "
+ DataBaseQuery.SCHEMA
+ "Zwerge (NR, NAME, TALENT, COMMENTS, ORDERID) "
+ "VALUES (6, 'Nase', 'Buddeln', 'nett', (select max(ORDERID)+1 from Zwerge))";

try {

// Inject DataSource
String ZwergEnv = System.getProperty("ZWERG_ENV");

// Create initial context
System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
"org.apache.naming.java.javaURLContextFactory");
System.setProperty(Context.URL_PKG_PREFIXES, "org.apache.naming");
InitialContext ctx = new InitialContext();

ctx.createSubcontext("java:");
ctx.createSubcontext("java:comp");
ctx.createSubcontext("java:comp/env");

// Construct DataSource
OracleConnectionPoolDataSource ds = new OracleConnectionPoolDataSource();
ds.setURL("jdbc:oracle:thin:@nitrium_stollen.de:1521:ZWERGE");
ds.setUser("aufseher");
ds.setPassword("Peitschenknall666");

ctx.bind("java:comp/env/ZwergDBResource_" + ZwergEnv, ds);

//get single connection
Connection conn = ds.getConnection();

//create prepared statement
PreparedStatement pstmt = conn.prepareStatement(sql);

//execute prepared statement in foreign class (simply pstmt.executeUpdate())
DataBaseQuery dbQuery = new DataBaseQuery();
result = Convert.toDouble(dbQuery.execSQLPreparedUpdate(pstmt));

if (dbQuery != null) {
dbQuery.closeResourcesWithoutException();
}

System.out.println("Update Result of Zwergen Update is " + Convert.toString(result));

} catch (Exception e) {
e.printStackTrace();
}

// added Zwerg
assertEquals("Test Result after Update", 1.0, result, 1.0);

}