I want to implement this methods functionality in my custom JDBC driver. Which method from JDBC should I use to setMaxResults? If my query results is 1000 rows and I have set the value for setFetchSize=100, then what will be the results? It will return only 100 row or after returning first 100 it will get nex…
Tag: jdbc
HP Fortify SQL injection issue on preparedStatement in java
I am using HP Fortify to measure code quality of my java code. HP Fortify is reporting SQL Injection error on so how to resolve this? Answer From my experience, HP Fortify will report an error on this scenario if it cannot trace the origin of all the Strings you are using to build your queryString to constant…
ArrayOutOfBoundsException on PreparedStatement
I’m at a loss here, can anyone see what’s wrong with this code? I’m using sqlite with this driver: https://bitbucket.org/xerial/sqlite-jdbc/downloads edit: fixed my initial error but have a similar one I get an exception at this line: stmt.setLong(1, tweet.getID()); The exception: This is ho…
Spring boot not executing schema.sql script
I’m developing a Spring Boot web application and want to create a MySql database if it’s not already created. So I’ve done a dump of my current database in order to have an empty schema of it. Put it in /src/main/resources, so maven brings it to /WEB-INF/classes when building the war file. T…
Fetching Oracle DB LONG type through jdbc works very slow
This happens only when the statement return LONG column. Even if i don’t do anything with it such like rs.getString, just execute. sql1: That was: 7593 ms sql2: That was: 530 ms As you can see it’s not about volume of data. When i use OracleConnection:OracleStatement:OracleCachedResultSet result i…
Returning ResultSet without close?
I would like to have a database connection managing class which I can use for simple SQL commands like SELECT, INSERT etc. by simple calling something like this (class below): This is class I’ve found on web: Is this way of returning ResultSet without closing it (and closing the statement) right? How ca…
Unable to create database using prepared statements in MySql
I am trying to create the database using a prepared statement in MySQL. Here I am passing the parameters as shown. But I am getting a syntax error. Is it possible to create tables and databases using prepared statements? Answer in a PreparedStatement can only be used to bind values (e.g., in where conditions …
Do you need a database transaction for reading data?
When I try to read data from the database, at least using ((Session)em.getDelegate()).createCriteria() an exception is throws saying that a transaction is not present. When I add the annotation: it works fine. However, since reading will happen million of times per second to access and read data, I want to ma…
Connecting to MySQL database using Java in command prompt
Since I don’t have netbeans right now, I am trying to connect to MySQL database from my Java code through command prompt. But it it is not taking the mysql-coonectivity.jar file. Does anyone know any way to run my program??? Please help. Answer Try executing the program as it is windows OS In case you d…
Unexpected GDS Exception: 335544726. Error reading data from the connection
I have a Web app running on Apache Tomcat 6, using ZK, Hibernate and Jaybird JDBC for accessing a Firebird database. For some unknown reason, after a not yet mapped operation in the app that performs a dynamic SQL, it crashes with the following exception: ERROR: org.springframework.transaction.TransactionSyst…