(New page: <source lang="java"> * * Get the Statement from SQL Connection. * @param conn the SQL Connection * @return: public static java.sql.Statement sqlGetStatement(java.sql.Connection co...)
 
Line 17: Line 17:
 
}
 
}
  
 +
public static void printErr(java.sql.SQLException ex) {
 +
System.out.println("SQL State: " + ex.getSQLState());
 +
System.out.println("Error Code: " + ex.getErrorCode());
 +
Ts.printErr((java.lang.Exception) ex);
 +
}
 +
 +
public static void printErr(java.lang.Exception ex) {
 +
ex.printStackTrace();
 +
System.exit(-1);
 +
}
  
 
</source>
 
</source>

Revision as of 16:35, 22 March 2011

/**
 * Get the Statement from SQL Connection.
 * @param conn the SQL Connection
 * @return
 */
public static java.sql.Statement sqlGetStatement(java.sql.Connection conn) {
	java.sql.Statement stat = null;
	try {
//			stat = conn.createStatement();
		stat = conn.createStatement(java.sql.ResultSet.TYPE_SCROLL_SENSITIVE, java.sql.ResultSet.CONCUR_READ_ONLY);
	} catch (java.sql.SQLException ex) {
		Ts.printErr(ex);
	}
	return stat;
}
 
public static void printErr(java.sql.SQLException ex) {
	System.out.println("SQL State: " + ex.getSQLState());
	System.out.println("Error Code: " + ex.getErrorCode());
	Ts.printErr((java.lang.Exception) ex);
}
 
public static void printErr(java.lang.Exception ex) {
	ex.printStackTrace();
	System.exit(-1);
}


Back to JavaHowTo

Alumni Liaison

Ph.D. on Applied Mathematics in Aug 2007. Involved on applications of image super-resolution to electron microscopy

Francisco Blanco-Silva