|
Java DataBase Connectivity[tm] FAQsWe want to hear from you! Please send us your FEEDBACK.
1. Where can I find tutorials including beginners information? The Java[tm] Tutorialhttp://java.sun.com/docs/books/tutorial/jdbc/index.html Four tutorials here: Getting Started with the JDBC[tm] API
2. Isn't there an existing FAQ for the Java DataBase Connectivity[tm] (JDBC[tm]) API? An exisiting FAQ for the JDBC API can be found here: http://java.sun.com/products/jdbc/faq.html This forum FAQ is intended to address common forum developer issues, raising the level of developer knowledge.
3. Is there any information regarding JDBC 3.0? Overview of the changes from the previous version: ~Savepoint support JDBC[tm] 3.0 shall ship with Java[tm] 2 Platform, Standard Edition (J2SE[tm]) version 1.4; you can download a pre-FCS release here. The J2SE 1.4 SDK JDBC
documents are available here: The specifications and further information are available here: http://java.sun.com/products/jdbc/download.html#corespec30
4. Where can I get drivers for my database? What are driver types? There is a searchable database of drivers also containing functionality information here: http://industry.java.sun.com/products/jdbc/drivers The types of drivers and Java[tm] 2 Platform, Enterprise Edition (J2EE[tm]) technology certified information are available from the "help" link under the appropriate section, as well as from the results sets.
5. Where can I learn more about JDBC - courses and books, for example? Courses:
JDBC Database Access with
Java[tm] Advanced Programming for the Java
2 Platform The Java Tutorial The Java Tutorial http://java.sun.com/docs/books/tutorial/jdbc/index.html Four tutorials here: Getting started with the JDBC
API
6. Please tell me about BLOBs/CLOBs in JDBC... These guides cover creating BLOBs/CLOBs,
manipulating and storing the data. Further information should also
be available from the database vendor or the driver vendor.
For CLOBs information, see: There is also further information in the JDBC specifications. See JDBC 3.0 above.
7. I keep getting a java.lang.OutOfMemoryError... "We are reading in 90,000 rows and obtain
a java.lang.OutOfMemoryError with no stack trace available"
One suggestion is to analyse what the driver is capable of offering and find the best and most efficient way of achieving the code purpose.
8. How could I use a properties file - to connect to the database, for example? It may be necessary to make properties
in the application flexible for different needs of users and changing environments,
instead of hardcoding properties to require recompilation upon a change.
Descriptions of ways to accomplish this, along with code snippets can be
found:
For J2SE 1.4
see:
9. Class not found problems... Using Class.forName(...) etc. you receive a ClassNotFoundException. Firstly, check that the class exists either in the JAR file or in the filesystem structure. If no class file exists then it may be that the driver has not been built or extracted correctly. Ensure that your classpath is set correctly including spelling of directories, paths and JAR file names. You may also want to make sure that the current directory is also in your classpath by adding "." to the classpath.
10. Can I serialize Java objects into the database? It is possible to store Java objects into a database.
"Storing Java
Objects in a Database" guide provides information on how SQL and Java types are mapped. "Support for Storing Java Objects" provides a small informational note.
11. How can I catch and use SQL exceptions? Here is a small snippet of code demonstrating how your Java program can handle the SQL exceptions generated from JDBC[tm] calls. try{
int errorcode = sqle.getErrorCode(); Switch(errorcode) {
case 1: System.out.println("Primary key violation"); break; A SQLException can have a list of the following exception objects: getNextException -returns the
next SQLException
12. How can I identify a database using a JDBC URL? jdbc:subprotocol:subname subprotocol
- driver or type of database connectivity mechanism jdbc:namingService:dataSrcName namingService
- the naming service should resolve the database name This requires Java Naming Directory Interface(JNDI) and JDBC 2.0 standard extensions. jdbc:odbc:dataSrcName[;attributeName=attributeValue] odbc subprotocol can also contain name-value pairs. jdbc:subprotocol://hostname:port/subsubname This URL specifies that the database is on a remote server. Back to Top
13. I've heard of SQLj, what is it? SQLj is a language for embedding static SQL in the Java[tm] programming language. It is an alternative method, in addition to the JDBC API, to connect a Java application to a relational database. You can combine the two in the same program and you would still need a JDBC driver to connect to the database. SQLj can be a better choice due to smaller source programs, and because it does compile-time checking. SQLj group Database Programming in
SQLj ORACLE® SQLj resource
14. We have a JDBC problem and are using ORACLE®... An excellent reference source can be found in Oracle Technology Network(OTN), namely "Oracle JDBC Developer's Guide and Reference".
15. Using ORACLE®, my updatable result set query cannot use "SELECT *" This is a limitation of the ORACLE® driver as a workaround try: SELECT mytable.* FROM TABLE mytable ...
16. Where can I find out about exisiting bugs and how can I report one? Firstly, check
to see if the bug has or is being addressed here: If need be, report
a new bug here:
17. Can I get Java Developer Support[sm] from Sun Microsystems? "Whether
you're a business manager trying to get to market quicker, or an individual
software developer learning new Sun technologies and need assistance, our
professional technical support staff and tools can help."
| |||||||||||||||||||||||||||||||||||||||||