Basically you are positioning the cursor before the first row and then requesting data. You need to move the cursor to the first row.
result.next();
String foundType = result.getString(1);
It is common to do this in an if statement or loop.
if(result.next()){
foundType = result.getString(1);
}
More Related Contents:
- SQL syntax error in "insert into 'keys'(a,b,c,d,e) values(?,?,?,?,?)" [closed]
- Hours and seconds are lost when storing a date in the database [closed]
- Connection pooling options with JDBC: DBCP vs C3P0 [closed]
- ClassNotFoundException com.mysql.jdbc.Driver [duplicate]
- Java: Insert multiple rows into MySQL with PreparedStatement
- What is the actual use of Class.forName(“oracle.jdbc.driver.OracleDriver”) while connecting to a database?
- How does a PreparedStatement avoid or prevent SQL injection?
- ClassCastException: java.math.BigInteger cannot be cast to java.lang.Long on connect to MySQL
- ResultSet to Pagination
- Closing JDBC Connections in Pool
- No suitable driver found for ‘jdbc:mysql://localhost:3306/mysql [duplicate]
- How to get a value from the last inserted row? [duplicate]
- How to enable logging for SQL statements when using JDBC
- SQL Server JDBC Error on Java 8: The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption
- Difference between Oracle jdbc driver classes?
- Writing a large resultset to an Excel file using POI
- Retrieve an Image stored as BLOB on a MYSQL DB
- UNIX socket implementation for Java? [closed]
- Can I execute multiple queries separated by semicolon with MySQL Connector/J? [duplicate]
- Spring-Boot: How do I set JDBC pool properties like maximum number of connections?
- mysql prepared statement error: MySQLSyntaxErrorException
- Call an Oracle function from Java
- SQL Error: 0, SQLState: 08S01 Communications link failure [duplicate]
- How to correctly write UTF-8 strings into MySQL through JDBC interface
- How to get the number of columns from a JDBC ResultSet?
- Resultset To List
- How do you enforce foreign key constraints in SQLite through Java?
- How to connect to a remote MySQL database with Java?
- Postgres UUID JDBC not working
- How to get jdbc connection from hibernate session? [duplicate]