1 23 package org.objectweb.clif.isac.plugins.jdbcsimple10.actions; 24 25 import java.sql.Connection ; 26 import java.sql.ResultSet ; 27 import java.sql.SQLException ; 28 import java.sql.Statement ; 29 import java.util.Hashtable ; 30 31 import org.objectweb.clif.isac.plugins.jdbcsimple10.SessionObject; 32 import org.objectweb.clif.storage.api.ActionEvent; 33 34 40 public class JDBCSample { 41 42 50 public static ActionEvent sqlRequest(SessionObject so, Hashtable params, ActionEvent report) { 51 Connection connection = so.getConnection() ; 53 String request = (String )params.get("sql_request") ; 55 report.type = "JDBC_sql_request" ; 57 ResultSet rs = null; 59 try { 60 report.setDate(System.currentTimeMillis()) ; 61 Statement stmt = connection.createStatement(); 62 rs = stmt.executeQuery(request); 63 report.successful = true ; 64 } 65 catch (SQLException se) { 66 report.comment = "Unable to execute the request "+se; 67 report.successful = false ; 68 } 69 finally { 70 report.duration = (int)(System.currentTimeMillis() - report.getDate()); 71 } 72 return report ; 73 } 74 75 } 76 | Popular Tags |