|
 |
pro_jsp thread: Re: How to get column of "Memo" type or LONGCHAR type?
Message #1 by "Roy Ngan" <kkngan@n...> on Fri, 1 Jun 2001 17:29:38 +0800
|
|
I think i'll go for Geert's suggestion to use the getAsciiStream.
But looking at the documentation, there don't seem to be any corresponding
JAVA type that supports sql "LONGCHAR" type.
Anyway, all the complication in trying to use MsAccess database with JSP,
defeats the whole purpose of using it in the first place, i.e. for a quick
prototype for a small project.
But, i'd like to thank you all for the quick and helpful responses.
I've learnt a lot, simply by being on this mailing list.
Thanks,
molly
At 05:29 PM 6/1/2001 +0800, Roy Ngan wrote:
>Molly, is the contents that you try to retrieve having a empty (or Null )
>value?
>
>you can use the try and catch.
>
>Regards,
>Roy Ngan
At 03:49 PM 5/31/2001 +0200, you wrote:
>I agree with Greg. You might consider using 'a database', not M$ Access ;-)
>
>besides that, check out the ResultSet class in the documentation. For large
>fields getAsciiStream (or getBinaryStream) might be more appropriate than
>getString().
>
>Geert Van Damme
>
>> -----Original Message-----
>> From: greg@c... [mailto:greg@c...]
>> Sent: donderdag 31 mei 2001 14:32
>> To: Pro_JavaServer_Pages
>> Subject: [pro_jsp] Re: How to get column of "Memo" type or LONGCHAR
>> type?
>>
>>
>> hmmm
>> except telling u to use something else as a database i can't tell much
>> sorry :-)
>>
>> greg
>> ----- Message d'origine -----
>> De : "molly" <medona@p...>
>> =C0 : "Pro_JavaServer_Pages" <pro_jsp@p...>
>> Envoy=E9 : jeudi 31 mai 2001 20:25
>> Objet : [pro_jsp] Re: How to get column of "Memo" type or LONGCHAR type?
>>
>>
>> > Hi Greg,
>> >
>> > Thanks for the feedback. I did try using getString initially, but it
did
>> > not work.
>> > Throws up the following error message.
>> >
>> > Error: 500
>> > Location: /travel/t.jsp
>> > Internal Servlet Error:
>> >
>> > javax.servlet.ServletException
>> > at
>> >
>> org.apache.jasper.runtime.PageContextImpl.handlePageException(Page
>> ContextImp
>> > l.java:459)
>> > at
_0002ft_0002ejspt_jsp_9._jspService(_0002ft_0002ejspt_jsp_9.java:106)
>> > at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
>> > at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
>> > at
>> >
>> org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(Jsp
>> Servlet.ja
>> > va:177)
>> > at
>> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:318)
>> > at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:391)
>> > at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
>> > at
>> org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
>> > at org.apache.tomcat.core.Handler.service(Handler.java:286)
>> > at
>> org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
>> > at
>> >
>> org.apache.tomcat.core.ContextManager.internalService(ContextManag
>> er.java:79
>> 7)
>> > at
>> org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
>> > at
>> >
>> org.apache.tomcat.service.connector.Ajp12ConnectionHandler.process
>> Connection
>> > (Ajp12ConnectionHandler.java:166)
>> > at
>> org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
>> > at
>>
org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)
>> > at java.lang.Thread.run(Thread.java:484)
>> >
>> > Root cause:
>> > java.sql.SQLException
>> > at
sun.jdbc.odbc.JdbcOdbcResultSet.getString(JdbcOdbcResultSet.java:285)
>> > at
sun.jdbc.odbc.JdbcOdbcResultSet.getString(JdbcOdbcResultSet.java:376)
>> > at _0002ft_0002ejspt_jsp_9._jspService(_0002ft_0002ejspt_jsp_9.java:77)
>> > at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
>> > at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
>> > at
>> >
>> org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(Jsp
>> Servlet.ja
>> > va:177)
>> > at
>> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:318)
>> > at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:391)
>> > at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
>> > at
>> org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
>> > at org.apache.tomcat.core.Handler.service(Handler.java:286)
>> > at
>> org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
>> > at
>> >
>> org.apache.tomcat.core.ContextManager.internalService(ContextManag
>> er.java:79
>> 7)
>> > at
>> org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
>> > at
>> >
>> org.apache.tomcat.service.connector.Ajp12ConnectionHandler.process
>> Connection
>> > (Ajp12ConnectionHandler.java:166)
>> > at
>> org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
>> > at
>>
org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)
>> > at java.lang.Thread.run(Thread.java:484)
>> >
>> >
>> > Thanks,
>> > molly
>> >
>> >
>> >
>> > At 01:16 PM 5/31/2001 +0200, you wrote:
>> > >Just a simple getString() will work
>> > >
>> > >greg
>> > >
>> > >> Hi,
>> > >>
>> > >> I've written a short JSP script that connects to a MsAccess database
>> and
>> > >> prints the results of the column called "background". The
>> column is of
>> > >> "memo" type which is equivalent to a "LONGCHAR" type.
>> > >>
>> > >> I'm not sure which type of getXXX i should use and how to
>> print out the
>> > >> results of the memo type.
>> > >>
>> > >> Appreciate your help in this.
>> > >>
>> > >> The following is the JSP script i'm working on.
>> > >>
>> > >>
>> > >> <%@ page language=3D"java" import=3D"java.sql.*" %>
>> > >> <%
>> > >> String driver =3D "sun.jdbc.odbc.JdbcOdbcDriver";
>> > >> String url =3D "jdbc:odbc:travel";
>> > >> String user =3D "";
>> > >> String password =3D "";
>> > >> String sqlstatement =3D "select countryid from country";
>> > >> Connection con;
>> > >>
>> > >> Class.forName(driver);
>> > >> con =3D DriverManager.getConnection(url, user, password);
>> > >> Statement stmt =3D con.createStatement();
>> > >> ResultSet rs =3D stmt.executeQuery("select * from country");
>> > >> while (rs.next()) {
>> > >> Object background =3D rs.getObject("background");
>> > >> %>
>> > >>
>> > >> <%=3D background %><br>
>> > >>
>> > >> <% } /* of while */ %>
>> > >>
>> > >>
>> > >> <%
>> > >> stmt.close();
>> > >> con.close();
>> > >> %>
>> > >>
>> > >>
>> > >> Thanks,
>> > >>
>> > >> molly
>> > >>
|
|
 |