JDBC Section Index
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
Use something like: // loads the JDBC driver Class.forName("org.gjt.mm.mysql.Driver").newInstance(); // get a database connection Connection conn = DriverManager.getConn...more
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
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?
Check out the jGuru Transactions FAQ.
Check out the jGuru Java400 FAQ.
Check out the jGuru EJB FAQ.
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.
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
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
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