All Downloads are FREE. Search and download functionalities are using the official Maven repository.

sqlg3.runtime.specific.Oracle Maven / Gradle / Ivy

Go to download

SQLG is a preprocessor and a library that uses code generation to simplify writing JDBC code

There is a newer version: 3.1
Show newest version
package sqlg3.runtime.specific;

import sqlg3.runtime.DBSpecific;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * {@link DBSpecific} implementation for Oracle.
 */
public final class Oracle implements DBSpecific {

    public static String getNextSeqSql(String sequence) {
        return "SELECT " + sequence + ".NEXTVAL FROM DUAL";
    }

    @Override
    public long getNextId(Connection conn, String sequence) throws SQLException {
        try (PreparedStatement stmt = conn.prepareStatement(getNextSeqSql(sequence));
             ResultSet rs = stmt.executeQuery()) {
            rs.next();
            return rs.getLong(1);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy