The connection url is invalid first. Message 8080 is commonly used by a web server such as Apache Tomcat. Oracle itself uses the default port 1521. Also see this Oracle JDBC documentation .
Next, you forgot to call ResultSet#next() . This will set the cursor to the next line in the result set. The result set is returned with the cursor before the first row. Any getXXX() calls to the ResultSet will fail if you do not move the cursor.
If you expect multiple rows in the result set, you need to use a while :
resultSet = statement.executeQuery(); while (resultSet.next()) { String columnname = resultSet.getString("columnname");
Or, if you expect only one line, you can also execute the if :
resultSet = statement.executeQuery(); if (resultSet.next()) { String columnname = resultSet.getString("columnname");
For more tips and examples on how to use basic JDBC correctly (also in JSP / Servlet), you can find this article . How you close an expression and a connection, for example, is subject to a resource leak. Also, loading a JDBC driver on a GET request is unnecessarily expensive. Just do this once during application startup or servlet initialization.
Balusc
source share