devxlogo

Avoid Java Null Pointer Exceptions with SQL-J

Avoid Java Null Pointer Exceptions with SQL-J

Direct access of a NULL in a column does not cause any problems in SQL-J. If you use that value as a parameter in a Java method or as a method receiver, you will get a Java Null Pointer Exception. The conditional expression is useful for avoiding Java-caused null pointer exceptions:

 SELECT empSurname.toUpperCase()FROM Actors-- If empSurname has any nulls, you'll get a null pointer exception SELECT (empSurname IS NULL) ?(empFirstname||'*') :empSurname.toUpperCase()FROM Actors 
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist