Home > Articles > Data

  • Print
  • + Share This
Like this article? We recommend

Querying the Database

After the connection has been obtained, standard java.sql classes (such as PreparedStatement, Statement, and RowSet) can be used to query the database and retrieve data. Because this concept should be familiar to Java developers, I'll just give a quick example here:

PreparedStatement tempStmt = conn.prepareStatement("select ID from CUSTOMER");
ResultSet result = tempStmt.executeQuery();

while (result.next()) {
ID = result.getInt(1);
}

result.close();
tempStmt.close();

Adaptive Server Anywhere databases also support the execution of Java classes in the database itself. The ASA runtime includes an internal Java VM that allows Java classes to be developed, installed in the database, and then accessed by SQL statements as functions. Java classes installed in the database can also be used as data types for columns in tables. The key point to take away from this discussion is that Java developers are first-class citizens in the ASA world. The full power of JDBC is made available to you, even on mobile devices.

  • + Share This
  • 🔖 Save To Your Account