JDBC Section Index
How do I check if a Connection is still valid / has been closed?
With JDBC 4.0, you can call the isValid(int timeout) method. The timeout represents the number of seconds to wait for a reply. If no reply is acquired during the time, false is returned and the ca...more
I am using ResultSetMetaData.getColumnLabel() to create headers for a table. I have specified column labels on the table ( DB2 on an AS/400, ) which show up when I run an SQL statement directly over the table, but the method returns the same data as getColumnName(). Any ideas, help or explanation?
Many drivers implement this method identically to getColumnName(), apparently because it is a "suggested" title, but always be sure you have the latest versions. For the AS/400 drivers ...more
How can I design my servlet/JSP so that query results get displayed on several pages, like the results of a search engine? Each page should display, say, 10 records each and when the next link is clicked, I should see the next/previous 10 records and so on.
Use a Java Bean to store the entire result of the search that you have found. The servlet will then set a pointer to the first line to be displayed in the page and the number of line...more
How can I connect to mysql database using jdbc?
Use something like:
// loads the JDBC driver
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
// get a database connection
Connection conn = DriverManager.getConn...more
What are the components of the JDBC URL for Oracle's "thin" driver and how do I use them?
Briefly: jdbc:oracle:thin:@hostname:port:oracle-sid
in green the Oracle sub-protocol (can be oracle:oci7:@, oracle:oci8:@, racle:thin:@, etc...) is related on the driver you are unsign and the p...more
Why doesn't JDBC accept URLs instead of a URL string?
In order for something to be a java.net.URL, a protocol handler needs to be installed. Since there is no one universal protocol for databases behind JDBC, the URLs are treated as strings. In Java ...more
Getting a newly created id. Is there any way I can determine the auto-generated number with MySQL after performing an insert without sending another query?
Getting a newly created id
Is there any way I can determine the auto-generated number with MySQL after performing an insert without sending another query?
Where can I learn (more) about Java's support for transaction processing?
Check out the jGuru
Transactions FAQ.
Where can I learn (more) about Java running on IBM's AS/400 series computers?
Check out the jGuru Java400
FAQ.
Where can I learn (more) about Java's EJB (Enterprise JavaBeans)?
Check out the jGuru EJB FAQ.
Where can I learn (more) about managing collections of data in Java?
Check out the jGuru
Collections FAQ.
JDBC - General Error. I am getting java.sql.SQLException: General error when working with my database. Please help me.
JDBC - General Error
I am getting java.sql.SQLException: General error when working with my database. Please help me.
Can I chain SQLWarnings?
Yes. SQLWarning is a subclass of SQLException. After the first warning is retrieved via getWarnings(), subsequent warnings are obtained in a way identical to SQLException chaining. You can see a...more
What JDBC objects generate SQLWarnings?
Connections, Statements and ResultSets all have a getWarnings method that allows retrieval. Keep in mind that prior ResultSet warnings are cleared on each new read and prior Statement warnings are...more
What is SQLException chaining?
There are often multiple reasons for a JDBC problem. SQLException has a method, getNextException, which returns either the next exception or null when all exceptions have been retrieved. Obtaini...more