|
 |
pro_jsp thread: How to get column of "Memo" type or LONGCHAR type?
Message #1 by molly <medona@p...> on Thu, 31 May 2001 18:53:14
|
|
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...>
> À : "Pro_JavaServer_Pages" <pro_jsp@p...>
> Envoyé : 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="java" import="java.sql.*" %>
> > >> <%
> > >> String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
> > >> String url = "jdbc:odbc:travel";
> > >> String user = "";
> > >> String password = "";
> > >> String sqlstatement = "select countryid from country";
> > >> Connection con;
> > >>
> > >> Class.forName(driver);
> > >> con = DriverManager.getConnection(url, user, password);
> > >> Statement stmt = con.createStatement();
> > >> ResultSet rs = stmt.executeQuery("select * from country");
> > >> while (rs.next()) {
> > >> Object background = rs.getObject("background");
> > >> %>
> > >>
> > >> <%= background %><br>
> > >>
> > >> <% } /* of while */ %>
> > >>
> > >>
> > >> <%
> > >> stmt.close();
> > >> con.close();
> > >> %>
> > >>
> > >>
> > >> Thanks,
> > >>
> > >> molly
> > >>
>
>
|
|
 |