JDBC prepared statement returns NullPointerException
See original GitHub issueExpected behavior and actual behavior
Calling a prepared statement via jdbc interface returns NullPointerException
Exception in thread “main” java.lang.NullPointerException at com.orientechnologies.orient.jdbc.OrientJdbcResultSetMetaData.getColumnType(OrientJdbcResultSetMetaData.java:192) at TestOrientdb.main(TestOrientdb.java:42)
A prepared statement should work without problems via jdbc interface.
Steps to reproduce the problem
Using the default database:
OrientJdbcConnection conn = (OrientJdbcConnection) DriverManager.getConnection("jdbc:orient:" + dbUrl, info);
//create and execute statement
String stmtStr = "SELECT FROM V WHERE song_type like ?";
PreparedStatement stmt = conn.prepareStatement(stmtStr);
stmt.setString(1, "original");
ResultSet rs = stmt.executeQuery();
int type = rs.getMetaData().getColumnType(1);
Important Questions
Runninng Mode
- Embedded, using PLOCAL access mode
- Embedded, using MEMORY access mode
- [ X] Remote
Misc
- I have a distributed setup with multiple servers. How many?
- I’m using the Enterprise Edition
OrientDB Version
- v2.0.x - Please specify last number:
- v2.1.x - Please specify last number:
- [X ] v2.2.x - Please specify last number: 0
Operating System
- Linux
- [X ] MacOSX
- Windows
- Other Unix
- Other, name?
Java Version
- 6
- 7
- [ X] 8
Issue Analytics
- State:
- Created 7 years ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
java - PreparedStatement throws NullPointerException
The problem is you never initialize conn . For instance, where you do this: Connection myConnection2 = dataSource.
Read more >Null Pointer Exception on stmt = conn.prepareStatement( query )
You set that to something in the previous line of code, so you must be setting it to null. Therefore the expression "DBConnection....
Read more >NullPointerException in PreparedStatement... - CodeRanch
The con is set in dbmodel.java and i extends that file with this file inorder to access the DB methods such as Statement,...
Read more >92089: PreparedStatement.setTimestamp NullPointerException
setTimestamp throws NPE if getParameterMetaData() is called before the statement is executed. This happens in 5.1.47. Rolling back to 5.1.46 ...
Read more >How to deal with NullPointerException in Java with Examples
Another common cause of NullPointerException is in JDBC code, where you set the parameter for calling stored procedure using CallableStatement or setting ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Check if you have included the mysql-jdbc-connector or the connector to your database library into your project.
No, sorry, is the javadoc from ResutlSet.getMetadata:
The problem is that at the JDBC level we don’t have all the info about the documents retrieved from Orient. And even if you work with plain OrientDB API what you get as a query result is a list od ODocuments, nothing more. On 3.0 we are working to overcome this, providing more metadata about the documents set returned by the database.