Tutorials to .com

Tutorials to .com » Jsp » Database » Learn how to handle null database

Learn how to handle null database

Print View , by: iSee ,Total views: 16 ,Word Count: 325 ,Date: Sat, 18 Apr 2009 Time: 10:06 PM

java database Connectivity (JDBC) type of result set to cover up a small bug, if you forget the words use wasNull methods. Relational database NULL value in the concept and java in the concept of null values similar to that which can be any type of null, but in Java, the basic data types can not be null. When a database to read a domain assigned to the basic types of time (for example, resultSet.getInt (1)), may cause problems. Examples of such norms has been to allow JDBC makers began to study how to solve this.

When the adoption of a value, such as getInt, getLong, getFloat this method getXxx get from the database, the developer can call wasNull () method to find out whether the value null. WasNull return if true, then the developer can choose to use the basic types of suitable null value. GetXxx value obtained is closely related to JDBC driver.

For example, in a database-driven, it return 0, and the other might return to the default values that are listed, and perhaps a return to drive out in that the last value read.

So when you are ready to read the value NULL in the database, the default values to be careful, you may need to be used to encode the following:

int idx = resultSet.getInt (1);
if (resultSet.wasNull ())
idx = -1; / / this is our default value for idx

Jsp And Database Articles

Can't Find What You're Looking For?

Rating: Not yet rated


No comments posted.