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: jdbc
COPY FROM and C3PO connection pool in Postgres
I have the follow code in my JAVA program that allows me to copy data from a file into my Postgres database: This code works fine, but I would like to use a connection pool to manage my connections, as I have this code running for numerous files. So I used C3P0. However, when i get a connection from the
Hibernate startup very slow
For some reason, the startup of my hibernate application is unbarrably slow. (up to 2 min) I have been thinking that the c3p0 configuration is plain wrong (related question) but studying the logs shows, that there is no activity just after the connection to the server is established. Also, using the built-in polling capabilities of Hibernate shows the same result.
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 query for a List in JdbcTemplate?
I’m using Spring’s JdbcTemplate and running a query like this: There are no named parameters being passed, however, column name, COLNAME, will be passed by the user. Questions Is there a way to have placeholders, like ? for column names? For example SELECT ? FROM TABLEA GROUP BY ? If I want to simply run the above query and get
java.sql.SQLException: Missing IN or OUT parameter at index:: 1
I made some Java 1.6-Oracle11g-JDBC (using OJDBC 6) code (below). I am getting an exception – java.sql.SQLException: Missing IN or OUT parameter at index:: 1 Why is this happening and how do I fix it ? My output is- The code is- EDIT – To correct the code, we use- //insert 1st row //insert 2nd row Answer This is not
How do insert a file like this into a MySQL Database
This the file I am trying to store in the database. I want to get the title and comments stored. I do get it in, but it stores only the first line. Please help, not really good with databases. Answer You first need to split line into Title and Comment and assign an id. Try this (note it is case
Creating a Java Connector for Pervasive PSQL
How can I create a connector for Pervasive PSQL in Java? How can I create a connector for Pervasive PSQL? I created a sample connector, but I am not sure whether it is right or wrong. Answer Here’s a simple program I have that works for me to connect to a Pervasive PSQL database: To compile it, I use: And
What is the reason for OutOfMemoryError: Java heap space in the following case?
The following code sample is inside a for loop that runs about 2 million times. stack trace: Please let me know if more information is required. Thank you. Thanks everyone for the answers. I will accept BalusC’s answer since he answered first. Unfortunately I cant upvote any other answers due to not enough reputation 🙁 Just a side note to
How to change MySQL timezone in a database connection using Java?
MySQL runs with timezone “GMT+8”, but Tomcat with “GMT”. When I save datetime to my database, everything seems to be OK, but when I check the datetime value in the database, I see the “GMT” value. Also when I try get the value from the database the value is changed, seems like the value in the database is taken as