jdbctemplate

How to format Interval type to HH:MM format?

浪尽此生 提交于 2021-02-11 16:29:10
问题 I am using oracle DB with below column START_TIME INTERVAL DAY(0) TO SECOND(0) I am using jdbc template in java code to access this value using the row mapper and getString() method like below: (I am running a basic select query to fetch values from DB) String startTime = rs.getString("START_TIME"); and the value I get is in this format System.out.println(startTime); // 0 9:30:0.0 I am not able to format this value in the HH:MM format string. I do not need the seconds as I am ignoring that

How to format Interval type to HH:MM format?

你。 提交于 2021-02-11 16:28:12
问题 I am using oracle DB with below column START_TIME INTERVAL DAY(0) TO SECOND(0) I am using jdbc template in java code to access this value using the row mapper and getString() method like below: (I am running a basic select query to fetch values from DB) String startTime = rs.getString("START_TIME"); and the value I get is in this format System.out.println(startTime); // 0 9:30:0.0 I am not able to format this value in the HH:MM format string. I do not need the seconds as I am ignoring that

How to create oracle connection in Spring application deployed in JBoss Server? (WrappedConnectionJDK6 cannot be cast to oracle.jdbc.OracleConnection)

笑着哭i 提交于 2021-02-08 09:51:14
问题 I want to create oracle connection. Currently i am passing jdbc connection to create struct descriptor and here i am getting exception as below. so to avoid this, required to create a java.sql.connection or oracle connection instead of getting from data source. org.jboss.resource.adapter.jdbc.jdk6.WrappedConnectionJDK6 cannot be cast to oracle.jdbc.OracleConnection java.lang.ClassCastException: org.jboss.resource.adapter.jdbc.jdk6.WrappedConnectionJDK6 cannot be cast to oracle.jdbc

How to create oracle connection in Spring application deployed in JBoss Server? (WrappedConnectionJDK6 cannot be cast to oracle.jdbc.OracleConnection)

爱⌒轻易说出口 提交于 2021-02-08 09:51:09
问题 I want to create oracle connection. Currently i am passing jdbc connection to create struct descriptor and here i am getting exception as below. so to avoid this, required to create a java.sql.connection or oracle connection instead of getting from data source. org.jboss.resource.adapter.jdbc.jdk6.WrappedConnectionJDK6 cannot be cast to oracle.jdbc.OracleConnection java.lang.ClassCastException: org.jboss.resource.adapter.jdbc.jdk6.WrappedConnectionJDK6 cannot be cast to oracle.jdbc

SQL state [99999]; error code [17004]; Invalid column type: 1111 With Spring SimpleJdbcCall

余生长醉 提交于 2021-02-07 05:51:38
问题 Hi All I am using spring simple JDBC template to call the oracle procedure the below are my code. The procedure create or replace PROCEDURE get_all_system_users( pi_client_code IN VARCHAR2, po_system_users OUT T_SYSTEM_USER_TAB, po_error_code OUT NUMBER, po_error_description OUT VARCHAR2) IS ctr NUMBER; sysUser SYSTEM_USER_OBJ; BEGIN ctr:=0; po_system_users:= t_system_user_tab(); end The Spring Dao class public class ManualSaleStoredProcedureDao { private SimpleJdbcCall getAllSytemUsers;

Java/Spring JDBC: Batch Insert into 2 Tables: Obtain FK ID from 1st Batch Insert Required for 2nd Table

谁说胖子不能爱 提交于 2021-02-05 10:48:21
问题 I'm using jdbcTemplate to Batch-Insert into 2 tables. The 1st table is easy, and has an ID . The 2nd table has an FK Reference USER_ID which I need to obtain from Table 1 before inserting. Suppose I have this: Main Java Code (here I split up into batches <= 1000) for(int i = 0; i < totalEntries.size(); i++) { // Add to Batch-Insert List; if list size ready for batch-insert, or if at the end, batch-persist & clear list batchInsert.add(user); if (batchInsert.size() == 1000 || i == totalEntries

How to test SimpleJdbcCall

狂风中的少年 提交于 2021-02-05 08:55:18
问题 I need to create test for this code. @Autowired JdbcTemplate jdbcTemplate; public List<Row> getData(int id) { // Preconditions here SimpleJdbcCall getCall = new SimpleJdbcCall(jdbcTemplate) .withSchemaName(SCHEMA) .withProcedureName(SP) .declareParameters( // ... ) .returningResultSet("result", (RowMapper<QuestionAnswerRow>) (rs, rowNum) -> .....); MapSqlParameterSource params = new MapSqlParameterSource(); params.addValue("id", id); // other parameters here Map queryRes = getCall.execute

How to test SimpleJdbcCall

半世苍凉 提交于 2021-02-05 08:54:28
问题 I need to create test for this code. @Autowired JdbcTemplate jdbcTemplate; public List<Row> getData(int id) { // Preconditions here SimpleJdbcCall getCall = new SimpleJdbcCall(jdbcTemplate) .withSchemaName(SCHEMA) .withProcedureName(SP) .declareParameters( // ... ) .returningResultSet("result", (RowMapper<QuestionAnswerRow>) (rs, rowNum) -> .....); MapSqlParameterSource params = new MapSqlParameterSource(); params.addValue("id", id); // other parameters here Map queryRes = getCall.execute

Method may fail to clean up stream or resource on checked exception — FindBugs

痞子三分冷 提交于 2021-01-27 03:53:46
问题 I am using Spring JDBCTemplate to access data in database and its working fine. But FindBugs is pointing me a Minor issue in my code snippet. CODE: public String createUser(final User user) { try { final String insertQuery = "insert into user (id, username, firstname, lastname) values (?, ?, ?, ?)"; KeyHolder keyHolder = new GeneratedKeyHolder(); jdbcTemplate.update(new PreparedStatementCreator() { public PreparedStatement createPreparedStatement(Connection connection) throws SQLException {

Method may fail to clean up stream or resource on checked exception — FindBugs

穿精又带淫゛_ 提交于 2021-01-27 03:52:57
问题 I am using Spring JDBCTemplate to access data in database and its working fine. But FindBugs is pointing me a Minor issue in my code snippet. CODE: public String createUser(final User user) { try { final String insertQuery = "insert into user (id, username, firstname, lastname) values (?, ?, ?, ?)"; KeyHolder keyHolder = new GeneratedKeyHolder(); jdbcTemplate.update(new PreparedStatementCreator() { public PreparedStatement createPreparedStatement(Connection connection) throws SQLException {