package testsuite.simple; import com.mysql.jdbc.NotUpdatable; import testsuite.BaseTestCase; import java.sql.DatabaseMetaData; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.sql.PreparedStatement; /** * Tests for select using latin2 encoding * @author Jim * @version $Id: Latin2SelectTest.java,v 1.0.0.0 2003/12/21 10:18:00 jim Exp $ */ public class Latin2SelectTest extends BaseTestCase { public Latin2SelectTest(String name) { super(name); } public static void main(String[] args) { new Latin2SelectTest("testLatin2Select").run(); } public void setUp() throws Exception { super.setUp(); createTestTable(); } public void testLatin2Select() throws SQLException { Statement scrollableStmt = null; try { PreparedStatement pstmt = conn.prepareStatement("SELECT * FROM MYUSER"); rs = pstmt.executeQuery(); while (rs.next()) { System.out.println("Record fetched (prepareStatement): "+rs.getString("NAME")); } pstmt = conn.prepareStatement("SELECT * FROM MYUSER WHERE NAME ='Őrmester_1'"); rs = pstmt.executeQuery(); while (rs.next()) { System.out.println("Record fetched (prepareStatement): "+rs.getString("NAME")); } } finally { if (scrollableStmt != null) { try { scrollableStmt.close(); } catch (SQLException sqlEx) { ; } } } } private void createTestTable() throws SQLException { try { stmt.executeUpdate("DROP TABLE MYUSER"); } catch (SQLException SQLE) { ; } stmt.executeUpdate( "CREATE TABLE MYUSER (ID int(6) not null, NAME varchar(255) not null, PRIMARY KEY (id))"); for (int i = 0; i < 10; i++) { stmt.executeUpdate("INSERT INTO MYUSER VALUES ("+i+",'Őrmester_"+i+"')"); } } }