import testsuite.*; import java.sql.*; public class bug20888_test extends BaseTestCase { private static int insertedRow = 0; public bug20888_test(String name) { super(name); } public static void main(String[] args) { junit.textui.TestRunner.run(bug20888_test.class); } public void setUp() throws Exception { super.setUp(); createTestTable(); } public void tearDown() throws Exception { try { this.stmt.executeUpdate("DROP TABLE IF EXISTS BUG20888_TEST"); } finally { super.tearDown(); } } private void createTestTable() throws Exception { try { this.stmt.executeUpdate("DROP TABLE IF EXISTS BUG20888_TEST"); } catch (SQLException SQLE) { ; } this.stmt.executeUpdate("CREATE TABLE `BUG20888_TEST` (`DetailedDescription` TEXT NOT NULL)"); } public void testPreparedStatement() throws Exception { String s = "INSERT INTO `BUG20888_TEST` VALUES ('What do you think about D\\'Artanian?')"; this.pstmt = this.conn.prepareStatement(s); this.pstmt.executeUpdate(); this.pstmt.clearParameters(); doRetrieval("Prepared statement test", "What do you think about D'Artanian?"); } private void doRetrieval(String message, String expectedResult) throws Exception { this.rs = this.stmt.executeQuery("SELECT * FROM BUG20888_TEST"); this.rs.next(); String actualResult = this.rs.getString(1); assertTrue( message + " has failed with expected result: '" + expectedResult + "' and actual: '" + actualResult + "'", 0 == expectedResult.compareTo(actualResult)); } }