import com.Ineb.Dguard.*; import com.Ineb.Exception.DguardLoginException; import com.Ineb.Exception.DguardNetworkException; import com.Ineb.Exception.DGuardPropertyException; import java.io.*; import java.sql.*; public class MySQLDec { static final String JDBC_DRIVER = "com.mysql.jdbc.Driver"; static final String DB_URL = "jdbc:mysql://192.168.100.211:3306/testdb"; static final String USERNAME = "ineb"; static final String PASSWORD = "ineb1234"; public static void main(String[] args) { DguardManager dm = null; Connection conn = null; PreparedStatement pstmt = null; ResultSet rset=null; try{ dm = DguardManager.Init("bidfunding", "Agent!1700", "Agent!1700", "/home/dguard/javaapi/conf/dguard.conf"); Class.forName(JDBC_DRIVER); conn = DriverManager.getConnection(DB_URL,USERNAME,PASSWORD); conn.setAutoCommit(false); System.out.println("- MySQL Connection"); String selectSql = "SELECT seq, data FROM tbl01"; pstmt = conn.prepareStatement(selectSql.toString()); rset = pstmt.executeQuery(); while(rset.next()){ int seq = rset.getInt("SEQ"); String data01 = rset.getString("data"); String decdata01 = dm.Decrypt("TBL", "ENC", data01); System.out.print("SEQ : " + seq + "\n"); System.out.print("DATA : " + data01 + "\n"); System.out.print("DEC : " + decdata01 + "\n"); } rset.close(); pstmt.close(); conn.close(); }catch(SQLException se1){ se1.printStackTrace(); }catch(Exception ex){ ex.printStackTrace(); }finally{ try{ if(pstmt!=null) pstmt.close(); }catch(SQLException se2){ } try{ if(conn!=null) conn.close(); }catch(SQLException se){ se.printStackTrace(); } } System.out.println("- MySQL Connection Close"); } }