I am using JDBC and new to it. but I keep getting this runtime exception: Here is the gave code how do I get this code to work? I am only a beginner with JDBC…. for the above code; PASS = “passowrd”, USER = “root” I had a problem with port which it was fixed through this site thanks a
Tag: sql
Hibernate faster EntityManagerFactory creation
In my desktop application new databases get opened quite often. I use Hibernate/JPA as an ORM. The problem is, creating the EntityManagerFactory is quite slow, taking about 5-6 Seconds on a fast machine. I know that the EntityManagerFactory is supposed to be heavyweight but this is just too slow for a desktop application where the user expects the new database
ResultSet getFetchSize() doesn’t seem to work?
I’m having trouble with the getFetchSize() function. I simply need to know if the SQL query has returned zero rows. I’ve tried this simple statement: where rs is of the ResultSet type. The above code doesn’t seem to work. It always prints the message whether rs is empty or not. I checked the SQL query itself and it correctly returned
How to prevent SQL Injection with JPA and Hibernate?
I am developing an application using hibernate. When I try to create a Login page, The problem of Sql Injection arises. I have the following code: How will i prevent Sql Injection in this scenario ?The create table syntax of loginInfo table is as follows: Answer You have other options too, see this nice article from mkyong.
SQLDeveloper runs query but getting a “ORA-00979: Not a Group By expression” from hibernate
I have data that looks something like this: And a query that works fine in Oracle SQL Developer (It returns data averaged over 15 second periods): but when I plug it into my java code, I get an error: The actual query string I use in the Jave looks more like this: and the parameters are set by calling: Anyone
What type of data structure should I use to hold table rows?
I’m new to Java and just getting into querying databases. So far I have my results in a ResultSetMetaData. I’m think that for each row in the dataset I should add it to some form of collection? Can anyone tell me the best practice for this? Thanks, Jonesy Answer Usually we have a class with fields that correspond to a
java.sql.SQLException: Exhausted Resultset
I get the error java.sql.SQLException: Exhausted ResultSet to run a query against an Oracle database. The connection is via a connection pool defined in Websphere. The code executed is as follows: I note that the resultset contains data (rs.next ()) Thanks Answer I’ve seen this error while trying to access a column value after processing the resultset. Hope this will
How to monitor slow SQL queries executed by JPA and Hibernate
Is there any Hibernate property I could set to see all the slow queries? I’, interested in queries that take too much time to return the result set. I’m using Spring with Hibernate, configured via an applicationContext.xml Spring configuration file. Answer I have 2 suggestions: you could use Oracle’s Statspack. you could use some kind of JDBC proxy driver logging
Cursor while loop returning every value but the last
I am using a while loop to iterate through a cursor and then outputing the longitude and latitude values of every point within the database. For some reason it is not returning the last (or first depending on if I use Cursor.MoveToLast) set of longitude and latitude values in the cursor. Here is my code: From this I am getting:
What are all the possible values for SQLException.getSQLState?
SQLException.getSQLState retrieves the SQLState for the SQLException object. What are all the possible values that can be returned by this method? Can I use the value to identify specific errors that occurred in the database (i.e. can this value tell me if it was a PK violation, or a unique constraint, or column value too large, etc.)? Also, the DatabaseMetaData.getSQLStateType()