Можно ли запустить подготовленный оператор в jdbc, который использует предложение with в одном операторе sql, примерно так
Код: Выделить всё
public class JdbcSample {
private static String jdbcUrl = "jdbc:demoapp:v2://localhost:8080";
private static List resultSets = new ArrayList();
public static void main(String[] args) throws Exception {
System.out.println("Starting the app.");
Connection connection = getConnection();
testPreparedQuery(connection);
}
public static void testPreparedQuery(Connection connection) throws SQLException {
String preparedSql = "with temp as (select ? from nation) select ? from temp";
PreparedStatement pStmt = connection.prepareStatement(preparedSql);
pStmt.setString(1,"col1");
ResultSet resultSet = pStmt.executeQuery();
resultSet.next();
}
public static Connection getConnection() throws SQLException {
AsgardDriver.registerDriver();
Driver driver = DriverManager.getDriver(jdbcUrl);
Properties props = new Properties();
Connection connection = driver.connect(jdbcUrl, props);
return connection;
}
}
Код: Выделить всё
java.lang.NullPointerExceptionИсточник: https://stackoverflow.com/questions/781 ... -statement