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