Code, JavaEE

Spring Named Parameter Jdbc Template

Doing it manually:


// Test doing it manually ------------------------------------------------
 BasicDataSource dataSource = new BasicDataSource();
 dataSource.setDriverClassName("oracle.jdbc.pool.OracleDataSource");
 dataSource.setUrl("jdbc:oracle:thin:@localhost:1234:development");
 dataSource.setUsername("SOMEUSER");
 dataSource.setPassword("SOMEPASSWORD");
 NamedParameterJdbcTemplate template = new NamedParameterJdbcTemplate(dataSource);

try {
  int numOfRowsUpdatedResult = template.update(SQL,params);
} catch (Exception ex) {
  // do something here to log, and respond to the exception.
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s