Example usage for java.sql Connection nativeSQL

List of usage examples for java.sql Connection nativeSQL

Introduction

In this page you can find the example usage for java.sql Connection nativeSQL.

Prototype

String nativeSQL(String sql) throws SQLException;

Source Link

Document

Converts the given SQL statement into the system's native SQL grammar.

Usage

From source file:Main.java

public static void main(String[] args) throws Exception {
    Connection conn = getConnection();
    conn.setAutoCommit(false);//w ww  .ja v a2  s .c  o  m
    Statement st = conn.createStatement();

    st.executeUpdate("create table survey (id int,myURL CHAR);");

    String str = conn.nativeSQL("insert into survey(id) values(02)");

    System.out.println(str);

    conn.commit();
    st.close();
    conn.close();
}

From source file:com.bluexml.side.Integration.alfresco.sql.synchronization.dialects.CreateTableStatement.java

public String getNativeSQL(Connection connection) {
    String createStatement = toSQLString();
    String query = null;//from  ww  w. j av a 2  s  .co m
    try {
        query = connection.nativeSQL(createStatement);
    } catch (SQLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    if (!createStatement.toString().equals(query)) {
        if (logger.isDebugEnabled())
            logger.debug("Original query : " + createStatement);
    }

    return query;
}

From source file:com.adaptris.jdbc.connection.FailoverDatasourceTest.java

@Test
public void testStatements() throws Exception {
    Connection conn = new MyProxy();
    try {//  w w w .  java2  s  .  c  o m
        try {
            conn.nativeSQL("SELECT * FROM SEQUENCES");
        } catch (Exception e) {

        }
        try {
            conn.createStatement();
        } catch (Exception e) {

        }
        try {
            conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
        } catch (Exception e) {

        }
        try {
            conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
        } catch (Exception e) {

        }
        try {
            conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE,
                    ResultSet.CLOSE_CURSORS_AT_COMMIT);
        } catch (Exception e) {

        }
        try {
            conn.prepareStatement("SELECT * FROM SEQUENCES");
        } catch (Exception e) {

        }
        try {
            conn.prepareStatement("SELECT * FROM SEQUENCES", ResultSet.TYPE_FORWARD_ONLY,
                    ResultSet.CONCUR_READ_ONLY);
        } catch (Exception e) {

        }
        try {
            conn.prepareStatement("SELECT * FROM SEQUENCES", ResultSet.TYPE_FORWARD_ONLY,
                    ResultSet.CONCUR_READ_ONLY, ResultSet.CLOSE_CURSORS_AT_COMMIT);
        } catch (Exception e) {

        }
        try {
            conn.prepareStatement("INSERT INTO sequences (id, seq_number) values ('id', 2)",
                    Statement.NO_GENERATED_KEYS);
        } catch (Exception e) {
        }
        try {
            conn.prepareStatement("INSERT INTO sequences (id, seq_number) values ('id', 2)", new int[0]);
        } catch (Exception e) {
        }
        try {
            conn.prepareStatement("INSERT INTO sequences (id, seq_number) values ('id', 2)", new String[0]);
        } catch (Exception e) {

        }

        try {
            conn.prepareCall("SELECT * FROM SEQUENCES");
        } catch (Exception e) {

        }
        try {
            conn.prepareCall("SELECT * FROM SEQUENCES", ResultSet.TYPE_FORWARD_ONLY,
                    ResultSet.CONCUR_READ_ONLY);
        } catch (Exception e) {

        }
        try {
            conn.prepareCall("SELECT * FROM SEQUENCES", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY,
                    ResultSet.CLOSE_CURSORS_AT_COMMIT);
        } catch (Exception e) {

        }
    } finally {
        JdbcUtil.closeQuietly(conn);

    }
}