using NT, SQL Server 7, and JDK1.3, getString on a null valued varchar field
evaluated successfully.
import java.sql.*;
public class SqlThis {
public static void main(String args[]) {
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:test");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("SELECT test2, test3 FROM
test");
while (rs.next()) {
String value = rs.getString("test3");
System.out.println(rs.getRow()+": "+value);
}
} catch (Exception e) {e.printStackTrace();}
}
}
-----Original Message-----
From: A mailing list about Java Server Pages specification and reference
[mailto:[EMAIL PROTECTED]]On Behalf Of Magnus Walter
Sent: Monday, August 14, 2000 7:30 AM
To: [EMAIL PROTECTED]
Subject: SV: JDBC-ODBC and NULL
Change the SQL statement, configure the table to use default values, use
some JavaScript to check the form values before submitting (app design
problem) will all FIX the problem BUT !
Can I check/handle NULL values in a recordset using JAVA (JDBC-ODBC) ?
Example:
I have a .jsp page for list all messages from table: tbl_msg (name
varchar(50),title varchar(100),msg text). Column msg may include null
values. If I found a null value in the msg column I will show nothing or do
some spec. action like include another .jsp page .......
Enviroment:
Wint NT, MS SQL Server 7.0, Tomcat 3.1 ...
So .... is it possible to check for null values in java, or handle null
values before the error ?
I'm very gratefull for all help !
/Mange
> -----Ursprungligt meddelande-----
> Fr�n: Selvamani Jayakumar [SMTP:[EMAIL PROTECTED]]
> Skickat: den 14 augusti 2000 20:52
> Till: [EMAIL PROTECTED]
> �mne: Re: JDBC-ODBC and NULL
>
> hi
>
> you can change the SQL statement to avoid null. Check the fields
> which will be null and replace with space. You can use
> the NVL funct in Oracle and ISNULL funct in SQL Serv.
> By this way you can avoid null values before getString.
> It doesnt chnge your database values too.
>
>
>
>
>
> >From: Magnus Walter <[EMAIL PROTECTED]>
> >Reply-To: A mailing list about Java Server Pages specification and
> > reference <[EMAIL PROTECTED]>
> >To: [EMAIL PROTECTED]
> >Subject: JDBC-ODBC and NULL
> >Date: Mon, 14 Aug 2000 13:58:51 +0200
> >
> >Hi,
> >need help with JDBC-ODBC and NULL values ?
> >
> >When I use getString and the value is null I got a ugly ERROR ! Is it
> >possible to check for NULL values before i use getString ?
> >(getString will give me the error so the method wasNull() dont help)
> >
> >Please help !
> >( I dont want to change the database and its null values)
> >
> >/Mange
> >
> >=========================================================================
> ==
> >To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> >JSP-INTEREST".
> >Some relevant FAQs on JSP/Servlets can be found at:
> >
> > http://java.sun.com/products/jsp/faq.html
> > http://www.esperanto.org.nz/jsp/jspfaq.html
> > http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> > http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
>
> ________________________________________________________________________
> Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com
>
> ==========================================================================
> =
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> JSP-INTEREST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
> http://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.html
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets