5. How can I use the JDBC API to access a desktop database like Microsoft Access over the network?Most desktop databases currently require a JDBC solution that uses ODBC underneath. This is because the vendors of these database products haven’t implemented all-Java JDBC drivers. The beat come is to use a commercial JDBC driver that supports ODBC and the database you want to use. See the JDBC drivers page for a enumerate of available JDBC drivers. The JDBC-ODBC bridge from Sun’s Java Software does not provide network access to desktop databases by itself. The JDBC-ODBC bridge loads ODBC as a local DLL and typical ODBC drivers for desktop databases like Access aren’t networked. The JDBC-ODBC bridge can be used together with the RMI-JDBC bridge however to access a desktop database like find over the net. This RMI-JDBC-ODBC solution is free.6. Does the JDK include the JDBC API and the JDBC-ODBC connect?Yes the JDK 1.1 and the Java 2 SDK. Standard Edition (formerly known as the JDK 1.2) include both the JDBC API and the JDBC-ODBC Bridge. The Java 2 SDK. Standard Edition contains the JDBC 2.0 core API which is the latest version. It does not include the JDBC 2.0 Optional Package which is move of the Java 2 SDK. Enterprise Edition or which you can download separately. say that the version of the JDBC API and the JDBC-ODBC Bridge provided for displace download on the JDBC download summon are only for use with the JDK 1.0.2.7. What JDBC technology-enabled drivers are available?See our web summon on JDBC technology-enabled drivers for a current listing.8. What documentation is available for the JDBC API?See the JDBC technology home summon for links to information about JDBC technology. This summon links to information about features and benefits a list of new features a divide on getting started online tutorials a divide on driver requirements and other information in addition to the specifications and javadoc documentation.9. Are there any ODBC drivers that do not work with the JDBC-ODBC Bridge?Most ODBC 2.0 drivers should bring home the bacon with the Bridge. Since there is some variation in functionality between ODBC drivers the functionality of the bridge may be affected. The bridge works with popular PC databases such as Microsoft Access and FoxPro.10. Does the JDBC-ODBC Bridge work with Microsoft J++?No. J++ does not give the JDBC-ODBC connect since it doesn’t implement the Java Native Interface (JNI). Any all-Java JDBC driver should bring home the bacon with J++ however.11. What causes the "No suitable driver" error?"No suitable driver" is an error that usually occurs during a label to the DriverManager getConnection method. The cause can be failing to load the appropriate JDBC drivers before calling the getConnection method or it can be specifying an invalid JDBC URL—one that isn’t recognized by your JDBC driver. Your best bet is to check the documentation for your JDBC driver or contact your JDBC driver vendor if you guess that the URL you are specifying is not being recognized by your JDBC driver. In addition when you are using the JDBC-ODBC Bridge this error can occur if one or more the the shared libraries needed by the connect cannot be loaded. If you evaluate this is the create analyse your configuration to be sure that the shared libraries are accessible to the Bridge.12. Why isn’t the java sql. DriverManager class being found?This problem can be caused by running a JDBC applet in a browser that supports the JDK 1.0.2 such as Netscape Navigator 3.0. The JDK 1.0.2 does not contain the JDBC API so the DriverManager class typically isn’t open by the Java virtual machine running in the browser. Here’s a solution that doesn’t require any additional configuration of your web clients. Remember that classes in the java.* packages cannot be downloaded by most browsers for security reasons. Because of this many vendors of all-Java JDBC drivers give versions of the java sql.* classes that have been renamed to jdbc sql.* along with a version of their driver that uses these modified classes. If you merchandise jdbc sql.* in your applet code instead of java sql.* and add the jdbc sql.* classes provided by your JDBC driver vendor to your applet’s codebase then all of the JDBC classes needed by the applet can be downloaded by the browser at run time including the DriverManager class. This solution ordain allow your applet to work in any client browser that supports the JDK 1.0.2. Your applet ordain also bring home the bacon in browsers that give the JDK 1.1 although you may want to switch to the JDK 1.1 classes for performance reasons. Also keep in object that the solution outlined here is just an example and that other solutions are possible.13. Why doesn’t calling the method Class forName fill my JDBC driver?There is a bug in the JDK 1.1 x that can create the method categorise forName to fail. A workaround is to explicitly call the method DriverManager registerDriver(new YourDriverClass()). The claim problem in the JDK is a go condition in the categorise loader that prevents the static divide of code in the driver categorise from executing and registering the driver with the DriverManager.14. Why do the java sql and java math packages fail to download java.* packages? Is there a workaround?For security reasons browsers will not transfer java.* packages. In order to use the JDBC API with browsers that have not been upgraded to JDK1.1 or beyond we recommend that the java sql and java math packages be renamed jdbc sql and jdbc math. Most vendors supplying JDBC technology-enabled drivers that are written purely in the Java programming language already provide versions of these renamed packages. When JDK 1.1 support has been added to your browser you should alter your applets back to the java.* case names.15. Why is the precision of java math. BigDecimal limited to 18 digits in the JDK 1.0.2 add-on version of the JDBC API?In JDK 1.1 java math. BigInteger is implemented in C. It supports a precision of thousands of digits. The same is true for BigDecigmal. The version of BigInteger provided with the JDK 1.0.2 add-on version of the JDBC API is a simplified version written in the Java programming language and it is limited to 18 digits. Because the implementation of BigDecimal is based on BigInteger it also is limited to this precision. In the JDBC 2.0 API you can use a new version of the method ResultSet getBigDecimal that does not take a scale parameter and returns a BigDecimal with beat precision.16. Can the JDBC API be added to JDK 1.0.2?Yes. transfer the JDBC 1.22 API from the JDBC transfer page and go the installation instructions in the channel notes. If you are using any version of the JDK from 1.1 on the JDBC API is already included and you should not download the JDBC 1.22 API.17. How do I retrieve a whole row of data at once instead of calling an individual ResultSet getXXX method for each column?The ResultSet getXXX methods are the only way to acquire data from a ResultSet object which means that you have to make a method call for each column of a row. It is unlikely that this is the create of a performance problem however because it is difficult to see how a column could be fetched without at least the cost of a function call in any scenario. We accept input from developers on this issue.18. Why does the ODBC driver manager return ‘Data obtain name not found and no default driver specified Vendor: 0’This type of error occurs during an attempt to connect to a database with the bridge. First note that the error is coming from the ODBC driver manager. This indicates that the bridge-which is a normal ODBC client-has successfully called ODBC so the problem isn’t due to native libraries not being show. In this case it appears that the error is due to the fact that an ODBC DSN (data source label) needs to be configured on the client forge. Developers often drop to do this thinking that the bridge ordain magically find the DSN they configured on their remote server machine19. Are all the required JDBC drivers to establish connectivity to my database move of the JDK?No. There aren’t any JDBC technology-enabled drivers bundled with the JDK 1.1 x or Java 2 Platform releases other than the JDBC-ODBC connect. So developers be to get a driver and install it before they can connect to a database. We are considering bundling JDBC technology- enabled drivers in the future.20. Is the JDBC-ODBC Bridge multi-threaded?No. The JDBC-ODBC Bridge does not give concurrent access from different threads. The JDBC-ODBC Bridge uses synchronized methods to serialize all of the calls that it makes to ODBC. Multi-threaded Java programs may use the Bridge but they won’t get the advantages of multi-threading. In addition deadlocks can become between locks held in the database and the semaphore used by the connect. We are thinking about removing the synchronized methods in the future. They were added originally to make things simple for folks writing Java programs that use a single-threaded ODBC driver.21. Does the JDBC-ODBC Bridge support multiple concurrent change state statements per connection?No. You can open only one Statement disapprove per connection when you are using the JDBC-ODBC connect.22. Does the JDBC-ODBC connect developed by Merant and Sun support result sets that contain Japanese Characters (DBCS)?Yes but we haven’t tested this ourselves. The version of the Bridge in the Java 2 SDK. Standard Edition and Java 2 SDK. Enterprise Edition also supports a new charSet Connection property for specifying the character encoding used by the underlying DBMS.23. Why can’t I create the ResultSet methods afterLast and beforeFirst when the method next works?You are probably using a driver implemented for the JDBC 1.0 API. You need to upgrade to a JDBC 2.0 driver that implements scrollable result sets. Also be sure that your code has created scrollable result sets and that the DBMS you are using supports them.24. How can I acquire a arrange or other object type without creating a new disapprove each time?Creating and garbage collecting potentially large numbers of objects (millions) unnecessarily can really hurt performance. It may be better to give a way to retrieve data desire strings using the JDBC API without always allocating a new object. We are studying this issue to see if it is an area in which the JDBC API should be improved. Stay tuned and gratify displace us any comments you have on this question.25. There is a method getColumnCount in the JDBC API. Is there a similar method to find the number of rows in a result set?No but it is easy to sight the be of rows. If you are using a scrollable result set rs you can call the methods rs measure and then rs getRow to find out how many rows rs has. If the result is not scrollable you can either ascertain the rows by iterating through the prove set or get the number of rows by submitting a query with a ascertain column in the decide clause.26. I would like to download the JDBC-ODBC Bridge for the Java 2 SDK. Standard Edition (formerly JDK 1.2). I’m a beginner with the JDBC API and I would like to go away with the connect. How do I do it?The JDBC-ODBC Bridge is bundled with the Java 2 SDK. Standard Edition so there is no need to download it separately.27. If I use the JDBC API do I have to use ODBC underneath?No this is just one of many possible solutions. We advise using a pure Java JDBC technology-enabled driver type 3 or 4 in order to get all of the benefits of the Java programming language and the JDBC API.28. Once I have the Java 2 SDK. Standard Edition from Sun what else do I need to cerebrate to a database?You comfort be to get and install a JDBC technology-enabled driver that supports the database that you are using. There are many drivers available from a variety of sources. You can also try using the JDBC-ODBC Bridge if you have ODBC connectivity set up already. The Bridge comes with the Java 2 SDK. Standard Edition and Enterprise Edition and it doesn’t demand any extra setup itself. The connect is a normal ODBC client. Note however that you should use the JDBC-ODBC Bridge only for experimental prototyping or when you have no other driver available.16What is a JDBC Driver?A JDBC driver is the set of classes that implement the JDBC interfaces for a particular database. There are four different types of JDBC driver: A write 1 driver is a JDBC-ODBC connect driver; this type of driver enables a client to cerebrate to an ODBC database via Java calls and JDBC—neither the database nor middle tier need to be Java compliant. However. ODBC binary code must be installed on each client forge that uses this driver. A Type 2 driver converts JDBC calls into calls for a specific database. This driver is referred to as a native-API partly Java driver. As with the Type 1 driver some binary code may be required on the client machine which means this write of driver is not suitable for downloading over a communicate to a client. A Type 3 driver is a JDBC-Net pure Java driver which translates JDBC calls into a database -independent net protocol. Vendors of database middleware products can apply this write of driver into their products to provide interoperability with the greatest number of database servers. Finally a Type 4 driver or native protocol pure Java driver converts JDBC calls into the network protocol used by the database directly. A write 4 driver requires no client software so it’s ideal for deployment to browsers at runtime. Each of these driver types has its own optimal usage scenarios and will alter the way you deploy a given Java application. For example because Type 4 drivers are 100% Java use Java sockets to connect to the database and require no client-side data access label they are ideal for applets or other download situations inside a firewall. Oracle’s JDBC DriversOracle provides both Type 2 and Type 4 drivers. All Oracle JDBC drivers support the full JDBC specification but in addition they give the extended capabilities of the Oracle database. For example the JDBC specification doesn’t give LOB data but the Oracle OCI8 JDBC driver does. Oracle’s implementation of the Type 2 JDBC driver is referred to as the Oracle "OCI driver," and the version of this driver that supports an Oracle 7 database is the OCI7 driver and the OCI8 supports Oracle 8. These drivers are platform specific; for example the Windows NT and Windows 95 version of the driver (oci805jdbc dll.) is implemented as a dynamic link library (DLL) in C. As mentioned previously. Type 2 drivers may demand client code. In the case of the OCI8 driver the clients must have Oracle’s Net*8 and all other dependent files loaded. A common way to implement Oracle OCI drivers is to use Oracle Application Server with the JWeb cartridge on the middle tier and deploy the client presentation logic as an applet; the interaction with the Oracle database is conducted from the lay tier only with just the results sent to the client applet as pure HTML or Java and HTML. All Oracle drivers are compliant with the Java Development Kit JDK 1.0 and 1.1 x and support the JDBC 1.22 standard. In addition all Oracle JDBC drivers support data types such as RAW and LONG RAW. ROWID and RECURSOR which are supported in Oracle databases but not part of the JDBC standard. Oracle’s drivers also support execution of PL/SQL stored procedures and anonymous blocks (for dynamic execution) andinclude capabilities such as row pre-fetching execution batching and defining query columns toreduce the communicate round trips to Oracle database. In addition the OCI driver for Oracle8 supports oracle data types CLOB. change surface. NCLOB and BFILE. The screenshot shows an example of one of the classes in the Oracle JDBC as move of the class hierarchy from which it descends as displayed in Oracle’s JDeveloper integrated development environment. As you can see the OraclePreparedStatement class inherits from the java sql. PreparedStatement class which in move inherits from the java sql. Statement. Oracle also provides a Type 4 JDBC driver referred to as the Oracle "thin" driver. This driver includes its own implementation of a TCP/IP version of Oracle’s Net8 written entirely in Java so it is platform independent can be downloaded to a browser at runtime and does not demand any Oracle software on the client side. This driver requires a TCP/IP listener on the server side and the client connection arrange uses the TCP/IP port communicate not the TNSNAMES entry for the database name.1. Add JDBC classes to your Java application or applet class by adding the following statement to your Java obtain code:import java sql.*;To use the extended capabilities of the Oracle database you must also import the Oracle JDBC driver. The statement in Java source looks like this:import oracle. JDBC driver.*2. fill the JDBC driver by including the following statement in your class. Class forName("oracle. JDBC driver. OracleDriver");You can fill the driver from your class-initialization routine.3. acquire a connection to an Oracle database by calling the getConnection() method of the JDBC DriverManager categorise. When you call this method you need to specify the connection information for the database in the create of a URL. The create the URL ordain act depends on the driver used. For example to use the pure Java write 4 Oracle driver (the thin driver) to connect to an Oracle7 database the URL would construe:jdbc:oracle:thin@database_name:port_no:SIDTo connect to an Oracle8 database using the OCI driver the URL would be more desire:jdbc:oracle:oci8@database_nameTo specify the database for use with an OCI driver you can use either a SQL*Net name- value pair or if you’re using an Oracle label server you can use the label from the tnsname ora register. (Both of these strings would conclude with the logon information as well—specifically the user name and password—but we’ve eliminated that from this example.)The preliminary driver and database-connection issues now taken care of there are comfort several other things your Java obtain label must include in order for the compiled label to submit queries to the database and process results.4. Create a Statement object by calling the createStatement() method of the Connection object you created in the previous go. The following statement creates a Statement object stmt:Statement stmt = channelise createStatement ();5. Once the Statement disapprove exists (in code) the application can then include code to execute a SQL query by calling the executeQuery() method of the Statement object. The executeQuery() method returns the result of the query in the ResultSet object. The following statement executes a query :ResultSet rset = stmt executeQuery (SELECT ename from emp where empno = 7900);6. Finally label the next() method of a ResultObject to acquire a row and show it. Use a loop if the ask returns more then one row from the database. For example the following statements get the name of an employee from the ResultSet disapprove and display it in the java awt text control placed on the GUI rset next();enameTxtb setText = ((String)rset getString(1));16JDBC (java database conctivity)1. What is JDBC ? what are its advantages ?A. It is an API. The latest version of jdbc api is (3.0). The JDBC 3.0 API is divided into two packages:(1) java sql and (2) javax sql. Both packages are included in the J2SE and J2EE platforms advantages:The JDBC API can be used to act with multiple data sources in a distributed heterogenous environment. It can connect to any of the database from java language. It can switch over to any backend database without changing java code or by minute changes.2. How many JDBC Drivers are there ? what are they?A. There are 4 types of JDBC drivers a. JDBC-ODBC connect Driver(Type-1 driver)b. Native API Partly Java Driver(Type-2 driver)c. Net protocol pure Java Driver(Type-3 driver)d. Native protocol Pure Java Driver(Type-4 driver)3. Explain about JDBC-ODBC driver(Type-1) ? When this write of driver is used ?A. In this mechanism the flow of execution ordain beJava code(JDBC API)
-------> The syntax of the subname is driver specific. The driver may choose any syntax allot for its implementationex: jdbc:odbc:dsnjdbc:oracle:oci8:@ database name jdbc:orale:thin:@ database name:port be:SID10. How do u fill a driver ?A. Using Driver Class forName(java lang. String driverclass) or registerDriver(Driver driver) .11 what are the types of resultsets in JDBC3.0 ?How you can acquire information of resultset?A. ScrollableResultSet and ResultSet. We can retrieve information of resultset by using java sql. ResultSetMetaData interface. You can get the dilate by calling the method getMetaData() on ResulSet disapprove.12 write the steps to Connect database?A. Class forName(The class name of a spasific driver);Connection c=DriverManager getConnection(url of a spasific driver,user label,password);Statement s=c createStatement();(or)PreparedStatement p=c prepareStatement();(or)CallableStatement cal=c prpareCall();Depending upon the requirement.13. Can java objects be stored in database? how?A. Yes. We can hold on java objects. BY using setObject(),setBlob() and setClob() methods in PreparedStatement14 what do u mean by isolation level?A. Isolation means that the business logic can speak withoutconsideration for the other activities of the system.15. How do u set the isolation level?A. By using setTransactionIsolation(int aim) in java sql. Connection interface level MEANS:-static final int TRANSACTION_construe_UNCOMMITTED //cannot prevent any reads static final int TRANSACTION_READ_COMMITTED //prevents dirty readsstatic final int TRANSACTION_REPEATABLE_READ //prevents dirty reads & non-repeatable read static final int TRANSACTION_SERIALIZABLE //prevents alter reads non-repeatable read & phantom construe. These are the static final fields in java sql. Connection interface.16 what is a dirty read?A. A Dirty read allows a row changed by one transaction to beread by another transaction before any change in the rowhave been committed. This problem can be solved by setting the transaction isolationlevel to TRANSACTION_READ_COMMITTED17 what is a non-repeatable read ?A. A non-repeatable read is where one transaction reads a row a secondtransaction alters or deletes the row and the first transactionre-reads the row,getting different values the second measure. This problem can be solved by setting the transaction isolationlevel to TRANSACTION_REPEATABLE_construe18 what is phantom construe?A. A phantom read is where one transaction reads all rows that satisfy a WHERE condition,a second transaction inserts a row that satisfies that WHERE condition,and the first transaction re-reads for the same condition,retrieving the additional ‘phantom’ row in the second construe This problem can be solved by setting the transaction isolation aim to TRANSACTION_SERIALIZABLE19. What is the difference between java sql. Statement &java sql. PreparedStatement ?A create verbally the appropriate situations to use these statements?20. How to retrieve the information about the database ?A we can retrieve the info about the database by using inerface java sql. DatabaseMetaData we can get this object by using getMetaData() method in Connection interface.21 what are the Different types of exceptions in jdbc?A. BatchUpdateExceptionDataTruncationSQLExceptionSQLWarning22. How to execute no of queries at one go?A. By using a batchUpdate’s (ie throw addBAtch() and executeBatch()) in java sql. Statement interface,or by using procedures.23 what are the advantages of connection pool. A. Performance24. In which interface the methods commit() & rollback() are defined ?A java sql. Connection interface25. How to store images in database?A. Using binary streams (ie getBinaryStream() ,setBinaryStream()). But it is not visable in database ,it is stored in create of bytes ,to make it visable we have to use any one frontend tool.26. How to analyse null value in JDBC?A. By using the method wasNull() in ResultSet ,it returns boolean value. Returns whether the measure column read had a value of SQL NULL. Note that you must first call one of the getXXX methods on a column to try to read its determine and then call the method wasNull to see if the determine construe was SQL NULL.27. furnish one Example of static Synchronized method in JDBC API?A getConnection() method in DriverManager class. Which is used to get object of Connection interface.28. What is a Connection?A. Connection is an interface which is used to make a connection between client and Database (ie opening a session with a particular database).29 what is the difference between kill() ,executeUpdate() and executeQuery() ? where we will use them?A kill() method returns a boolean value (ie if the given ask returns a resutset then it returns adjust else false),so depending upon the go value we can get the ResultSet object (getResultset())or we can experience how many rows undergo bean affected by our query (getUpdateCount()). That is we can use this method for Fetching queries and Non-Fetching queries. Fetching queries are the queries which are used to fetch the records from database (ie which returns resutset) ex: Select * from emp. Non-Fetching queries are the queries which are used to update,attach,create or delete the records from databaseex: modify emp set sal=10000 where empno=7809 executeUpdate() method is used for nonfetching queries which returns int value executeQuery() method is used for fetching queries which returns ResulSet disapprove ,Which contains methods to fetch the values.30. How is jndi useful for Database connection?
Forex Groups - Tips on Trading
Related article:
http://javaj2eeplanet.blogspot.com/2007/10/jdbc-faqs.html
comments | Add comment | Report as Spam
|