Skip to content
Advertisement

Tag: jdbc

How JDBC Statement.setFetchsize exactly works

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 next 100 from db

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 how I created the table Answer As per the docs at http://docs.oracle.com/javase/7/docs/api/java/sql/PreparedStatement.html#setLong(int,%20long)

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. That’s how my application.properties is configured (according to

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 is the same. Also i tried to use OracleCachedRowSet instead of ResultSet. Problem

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 can I return the ResultSet from the method?

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 make sure that our environment is not clogged up unnecessarily.

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 don’t have the mysql-connector-java-[version].jar get

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.TransactionSystemException: Could not roll back JPA transaction; nested exception is javax.persistence.PersistenceException: unexpected error when

Advertisement