A default ResultSet object is not updatable and has a cursor that moves forward only. It is possible to produce ResultSet objects that are updatable. The following code fragment, in which con is a valid Connection object, illustrates how to make a result set that is scrollable and insensitive to updates by others, and that is updatable. Statement stmt = con.createStatement( ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE); ResultSet rs = stmt.executeQuery("SELECT a, b FROM TABLE2"); // rs will be scrollable, will not show changes made by others, // and will be updatable.
SOURCE : www.referjava.com
Tuesday, February 6, 2007
what are the types of resultsets
TYPE_FORWARD_ONLY
The result set is nonscrollable; its cursor moves forward only, from top to bottom.
The view of the data in the result set depends on whether the DBMS materializes results incrementally.
TYPE_SCROLL_INSENSITIVE
The result set is scrollable: Its cursor can move forward or backward and can be moved to a particular row or to a row whose position is relative to its current position.
The result set generally does not show changes to the underlying database that are made while it is open. The membership, order, and column values of rows are typically fixed when the result set is created.
TYPE_SCROLL_SENSITIVE
The result set is scrollable; its cursor can move forward or backward and can be moved to a particular row or to a row whose position is relative to its current position.
The result set is sensitive to changes made while it is open. If the underlying column values are modified, the new values are visible, thus providing a dynamic view of the underlying data. The membership and ordering of rows in the result set may be fixed or not, depending on the implementation
SOURCE : www.referjava.com
The result set is nonscrollable; its cursor moves forward only, from top to bottom.
The view of the data in the result set depends on whether the DBMS materializes results incrementally.
TYPE_SCROLL_INSENSITIVE
The result set is scrollable: Its cursor can move forward or backward and can be moved to a particular row or to a row whose position is relative to its current position.
The result set generally does not show changes to the underlying database that are made while it is open. The membership, order, and column values of rows are typically fixed when the result set is created.
TYPE_SCROLL_SENSITIVE
The result set is scrollable; its cursor can move forward or backward and can be moved to a particular row or to a row whose position is relative to its current position.
The result set is sensitive to changes made while it is open. If the underlying column values are modified, the new values are visible, thus providing a dynamic view of the underlying data. The membership and ordering of rows in the result set may be fixed or not, depending on the implementation
SOURCE : www.referjava.com
what are the advantages of callable statements over prepared statements?
CallableStatement inherits Statement methods, which deal with SQL statements in general, and it also inherits PreparedStatement methods, which deal with IN parameters. All of the methods defined in CallableStatement deal with OUT parameters>OUT parameters or the output aspect of INOUT parameters: registering the JDBC types of the OUT parameters, retrieving values from them, or checking whether a returned value was JDBC NULL. Whereas the getter methods defined in ResultSet (getString, getLong, and so on) retrieve values from a result set, the getter methods in CallableStatement retrieve values from the OUT parameters and/or return value of a stored procedure
SOURCE : www.referjava.com
SOURCE : www.referjava.com
What is the fastest type of JDBC driver?
JDBC driver performance will depend on a number of issues:
the quality of the driver code,
the size of the driver code,
the database server and its load,
network topology,
the number of times your request is translated to a different API.
In general, all things being equal, you can assume that the more your request and response change hands, the slower it will be. This means that Type 1 and Type 3 drivers will be slower than Type 2 drivers (the database calls are make at least three translations versus two), and Type 4 drivers are the fastest (only one translation).
SOURCE : www.referjava.com
the quality of the driver code,
the size of the driver code,
the database server and its load,
network topology,
the number of times your request is translated to a different API.
In general, all things being equal, you can assume that the more your request and response change hands, the slower it will be. This means that Type 1 and Type 3 drivers will be slower than Type 2 drivers (the database calls are make at least three translations versus two), and Type 4 drivers are the fastest (only one translation).
SOURCE : www.referjava.com
Is the JDBC-ODBC Bridge multi-threaded?
No. The JDBC-ODBC Bridge does not support 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 occur between locks held in the database and the semaphore used by the Bridge. 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.
SOURCE : www.referjava.com
SOURCE : www.referjava.com
Can the JDBC-ODBC Bridge be used with applets?
Use of the JDBC-ODBC bridge from an untrusted applet running in a browser, such as Netscape Navigator, isn't allowed. The JDBC-ODBC bridge doesn't allow untrusted code to call it for security reasons. This is good because it means that an untrusted applet that is downloaded by the browser can't circumvent Java security by calling ODBC. Remember that ODBC is native code, so once ODBC is called the Java programming language can't guarantee that a security violation won't occur. On the other hand, Pure Java JDBC drivers work well with applets. They are fully downloadable and do not require any client-side configuration.
Finally, we would like to note that it is possible to use the JDBC-ODBC bridge with applets that will be run in appletviewer since appletviewer assumes that applets are trusted. In general, it is dangerous to turn applet security off, but it may be appropriate in certain controlled situations, such as for applets that will only be used in a secure intranet environment. Remember to exercise caution if you choose this option, and use an all-Java JDBC driver whenever possible to avoid security problems.
SOURCE : www.referjava.com
Finally, we would like to note that it is possible to use the JDBC-ODBC bridge with applets that will be run in appletviewer since appletviewer assumes that applets are trusted. In general, it is dangerous to turn applet security off, but it may be appropriate in certain controlled situations, such as for applets that will only be used in a secure intranet environment. Remember to exercise caution if you choose this option, and use an all-Java JDBC driver whenever possible to avoid security problems.
SOURCE : www.referjava.com
What are the Five (5) Transaction Isolation levels in JDBC Connection.
1. Transaction None.
2. Transaction Read Uncommited.
3. Transaction Read Commited.
4. Transaction Repeatable Read
5. Transaction Serializable.
SOURCE : www.referjava.com
2. Transaction Read Uncommited.
3. Transaction Read Commited.
4. Transaction Repeatable Read
5. Transaction Serializable.
SOURCE : www.referjava.com
Subscribe to:
Posts (Atom)