1 | private Timestamp usePreparedStatement(String timestampSelectString, SessionImplementor session) {↵ | | 1 | private Timestamp useCallableStatement(String callString, SessionImplementor session) {↵
|
2 | PreparedStatement ps = null;↵ | | 2 | CallableStatement cs = null;↵
|
3 | try {↵ | | 3 | try {↵
|
4 | ps = session.getBatcher().prepareStatement( timestampSelectString );↵ | | 4 | cs = session.getBatcher().prepareCallableStatement( ↵
|
5 | ResultSet rs = session.getBatcher().getResultSet( ps↵ | | 5 | callString );↵
|
6 | );↵ | | 6 | cs.registerOutParameter( 1, java.sql.Types.TIMESTAMP );↵
|
7 | rs.next();↵ | | 7 | cs.execute();↵
|
8 | Timestamp ts = rs.getTimestamp( 1 );↵ | | 8 | Timestamp ts = cs.getTimestamp( 1 );↵
|
9 | if ( log.isTraceEnabled() ) {↵ | | 9 | if ( log.isTraceEnabled() ) {↵
|
10 | log.trace(↵ | | 10 | log.trace(↵
|
11 | "current timestamp retreived from db : " + ts +↵ | | 11 | "current timestamp retreived from db : " + ts +↵
|
12 | " (nanos=" + ts.getNanos() +↵ | | 12 | " (nanos=" + ts.getNanos() +↵
|
13 | ", time=" + ts.getTime() + ")"↵ | | 13 | ", time=" + ts.getTime() + ")"↵
|
14 | );↵ | | 14 | );↵
|
15 | }↵ | | 15 | }↵
|
16 | return ts;↵ | | 16 | return ts;↵
|
17 | }↵ | | 17 | }↵
|
18 | catch( SQLException sqle ) {↵ | | 18 | catch( SQLException sqle ) {↵
|
19 | throw JDBCExceptionHelper.convert(↵ | | 19 | throw JDBCExceptionHelper.convert(↵
|
20 | session.getFactory().getSQLExceptionConverter(),↵ | | 20 | session.getFactory().getSQLExceptionConverter(),↵
|
21 | sqle,↵ | | 21 | sqle,↵
|
22 | "could not select current db timestamp",↵ | | 22 | "could not call current db timestamp function",↵
|
23 | timestampSelectString↵ | | 23 | callString↵
|
24 | );↵ | | 24 | );↵
|
25 | }↵ | | 25 | }↵
|
26 | finally {↵ | | 26 | finally {↵
|
27 | if ( ps != null ) {↵ | | 27 | if ( cs != null ) {↵
|
28 | try {↵ | | 28 | try {↵
|
29 | session.getBatcher().closeStatement( ps );↵ | | 29 | session.getBatcher().closeStatement( cs );↵
|
30 | }↵ | | 30 | }↵
|
31 | catch( SQLException sqle ) {↵ | | 31 | catch( SQLException sqle ) {↵
|
32 | log.warn( "unable to clean up prepared statement", sqle );↵ | | 32 | log.warn( "unable to clean up callable statement", sqle );↵
|
33 | | | 33 |
|