Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_jsp thread: Problem with database access


Message #1 by "Tiago Rocha" <tiago@b...> on Wed, 6 Sep 2000 08:32:43 -0300
I found a way to make it work...

Just use
public void doSomething() throws Exception

instead
public void doSomething()

with the jdbc code inside...

Thanks,
Tiago



-----Original Message-----
From: J.T. Wenting [mailto:jwenting@h...]
Sent: Quarta-feira, 6 de Setembro de 2000 09:57
To: Pro_JavaServer_Pages
Subject: [pro_jsp] RE: Problem with database access


Logical if you think about it. These statements are not declarations, and
therefore have no place in a declare section.

Jeroen T. Wenting
jwenting@h...

Murphy was wrong, things that can't go wrong will anyway

> -----Original Message-----
> From: Tiago Rocha [mailto:tiago@b...]
> Sent: Wednesday, September 06, 2000 22:15
> To: Pro_JavaServer_Pages
> Subject: [pro_jsp] Problem with database access
>
>
> Hi,
>
> I have a .jsp file that access a database using jdbc, with the followind
> code:
>
> <%
> Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
> Connection myConn = DriverManager.getConnection("jdbc:odbc:cecrisa");
> Statement stmt = myConn.createStatement();
> ResultSet myResults = stmt.executeQuery( "some sql here" );
>
> %>
>
> Everything goes ok with the code above, but, when I try to do the same in
> the declarations segment, I cause an error. This is the code:
>
> <%!
> Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
> Connection myConn = DriverManager.getConnection("jdbc:odbc:cecrisa");
> Statement stmt = myConn.createStatement();
> ResultSet myResults = stmt.executeQuery( "some sql here" );
>
> public void doSomething()
> {
> 	//some code
> }
>
> %>
>
> Or also:
>
> <%!
> public void doSomething()
> {
> 	Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
> 	Connection myConn 
> DriverManager.getConnection("jdbc:odbc:cecrisa");
> 	Statement stmt = myConn.createStatement();
> 	ResultSet myResults = stmt.executeQuery( "some sql here" );
> }
>
> %>
>
>
> In both cases above the same error occurrs.
> Had someone this kind of problem?
>
> Regards,
> Tiago
>
>
>
>
>
> ---
> Do you know what you want from this list? How would you provide
> programmers with the solutions they need? If you have the
> answers, and are willing to work in Birmingham (UK), then you
> could be a List Manager. Please send CVs and a covering letter to
> listsupport@p... for further information.


---
Do you know what you want from this list? How would you provide programmers
with the solutions they need? If you have the answers, and are willing to
work in Birmingham (UK), then you could be a List Manager. Please send CVs
and a covering letter to listsupport@p... for further information.


  Return to Index