1 24 25 package org.objectweb.cjdbc.scenario.tools.testlet; 26 27 import java.sql.Blob ; 28 import java.sql.Connection ; 29 import java.sql.PreparedStatement ; 30 31 37 public class SmallBlobTestLet extends AbstractConnectionTestLet 38 { 39 40 45 public SmallBlobTestLet(Connection con) 46 { 47 super(con); 48 config.put(TABLE_NAME, "blobtable"); 49 config.put(COLUMN_NAME, "name"); 50 config.put(UPDATED_COLUMN_VALUE, "ind\\igo"); 51 config.put(USE_TRANSACTIONS,"false"); 52 } 53 54 57 public void execute() throws Exception 58 { 59 String query = "Update " + config.get(TABLE_NAME) + " set "+config.get(COLUMN_NAME)+"=? where id='3'"; 60 String data = (String )config.get(UPDATED_COLUMN_VALUE); 61 if(useTransaction()) 62 jdbcConnection.setAutoCommit(false); 63 PreparedStatement ps1 = jdbcConnection.prepareStatement(query); 64 Blob bob = new org.objectweb.cjdbc.driver.Blob(data.getBytes()); 65 ps1.setBlob(1, bob); 66 ps1.executeUpdate(); 67 byte[] bobdata = bob.getBytes(1, (int) bob.length()); 68 String testdata = new String (bobdata); 69 assertTrue(bob != null); 70 assertTrue(bobdata != null && data.equalsIgnoreCase(testdata)); 71 if(useTransaction()) 72 jdbcConnection.commit(); 73 } 74 75 } 76 | Popular Tags |