import java.sql.*; /** * HelloWorldExample : JDBC Tutorial that creates a simple database, stores in a single row * and retrieves the data to then be displayed on standard out. The database is cleaned up * to reduce clutter for this example. * Author: Kevin Hooks * Date: April 18th, 2012 **/ public class HelloWorldExample { public static void main(String[] args) throws SQLException{ // Note that you can use TCP/IP by using this URL // "jdbc:raima:rdm://localhost" // The rdmsqlserver must be running to use TCP/IP Connection Conn = DriverManager.getConnection("jdbc:raima:rdm://local"); try { Statement Stmt = Conn.createStatement(); try { try { //Since the database is created here, it cannot be created twice Stmt.execute("DROP DATABASE hello_db"); } catch (SQLException exception) {} Stmt.execute("CREATE DATABASE hello_Db"); Stmt.execute("CREATE TABLE hello_table (f00 char(31))"); Conn.commit(); PreparedStatement PrepStmt = Conn.prepareStatement("INSERT INTO hello_table (f00) VALUES (?)"); try { //Sets parameter value to a string PrepStmt.setString(1, "Hello World!"); PrepStmt.execute(); Conn.commit(); ResultSet RS = Stmt.executeQuery("SELECT * FROM hello_table"); try { while(RS.next() != false) { System.out.println(RS.getString(1)); } } finally { RS.close(); } } finally { //Cleans up by dropping database in this case Stmt.execute("DROP DATABASE hello_db"); PrepStmt.close(); } } finally { Stmt.close(); } } catch (SQLException exception) { System.err.println("SQLException: " + exception.toString()); }finally { Conn.close(); } } }