private Timestamp usePreparedStatement(String timestampSelectString, SessionImplementor session) { PreparedStatement ps = null; try { ps = session.getBatcher().prepareStatement( timestampSelectString ); ResultSet rs = session.getBatcher().getResultSet( ps ); rs.next(); Timestamp ts = rs.getTimestamp( 1 ); if ( log.isTraceEnabled() ) { log.trace( "current timestamp retreived from db : " + ts + " (nanos=" + ts.getNanos() + ", time=" + ts.getTime() + ")" ); } return ts; } catch( SQLException sqle ) { throw JDBCExceptionHelper.convert( session.getFactory().getSQLExceptionConverter(), sqle, "could not select current db timestamp", timestampSelectString ); } finally { if ( ps != null ) { try { session.getBatcher().closeStatement( ps ); } catch( SQLException sqle ) { log.warn( "unable to clean up prepared statement", sqle );
private Timestamp useCallableStatement(String callString, SessionImplementor session) { CallableStatement cs = null; try { cs = session.getBatcher().prepareCallableStatement( callString ); cs.registerOutParameter( 1, java.sql.Types.TIMESTAMP ); cs.execute(); Timestamp ts = cs.getTimestamp( 1 ); if ( log.isTraceEnabled() ) { log.trace( "current timestamp retreived from db : " + ts + " (nanos=" + ts.getNanos() + ", time=" + ts.getTime() + ")" ); } return ts; } catch( SQLException sqle ) { throw JDBCExceptionHelper.convert( session.getFactory().getSQLExceptionConverter(), sqle, "could not call current db timestamp function", callString ); } finally { if ( cs != null ) { try { session.getBatcher().closeStatement( cs ); } catch( SQLException sqle ) { log.warn( "unable to clean up callable statement", sqle );
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/type/DbTimestampType.java File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/type/DbTimestampType.java
Method name: Method name:
Number of AST nodes: 0 Number of AST nodes: 0
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
				
Summary
Number of common nesting structure subtrees0
Number of refactorable cases0
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.0
Clones location
Number of node comparisons0