Add :
   <%@ page language="java" import="java.sql.*, java.util.*" %>

----- Original Message -----
From: Halterman, Jon <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, October 25, 2000 12:15 PM
Subject: JSP/JDBC Problems


> Hi,
>
> I am relatively new to the Java and JSP and JDBC worlds.  I am attempting
to
> write a simple JSP to prove to myself that it is possible to connect a JSP
> file to an Oracle database.
>
> I have two java classes: TRSQLTest.java and TestMe.java.  TRSQLTest is
> responsible for connecting to the database and has two methods.  getTables
> returns a record set of the table names available to the user.
getTableDesc
> returns a record set of the field/column names of a given table.  TestMe
is
> a command line version of what I would like to do (minimally) on the web.
> It lists each table name and displays the column names associated with
that
> table. [source for both is below]
>
> TestMe works fine.  My jsp file is as follows:
>
> <%@ page info="Track Record Database SQL Test" %>
> <%@ page import="TRSQLTest" %>
>
> <jsp:useBean id="trSQLBean" scope="Page" class="TRSQLTest" />
>
> <html>
> <% response.setDateHeader( "Expires", 0 ); %>
> <body>
>
> <!--%
>   ResultSet rs = trSQLBean.getTables();
>   while (rs.next()) {
>     response.write(rs.getString(1));
>   }
> %-->
>
> </body>
>
> </html>
>
> If I comment out the <jsp:useBean...../> tag, the page will at least load,
> otherwise I get the following error:
>
> Error: 500
> Location: /TrackRecord/test.jsp
> Fatal Error: missing resource: java.util.PropertyResourceBundle
>
> I have tried a variety of things to rectify this problem.  Unfortunately
> with my inexperience in the java world, I can't seem to figure it out.  I
am
> sure it is something simple.
>
> Thanks in advance for your help,
>
> Jonathan Halterman
>
>
> ********* TRSQLTest.java
> import java.sql.*;
> import java.util.*;
>
> public class TRSQLTest {
>   private String username;
>   private String password;
>   private String dbURL;
>   private Connection conn;
>
>   public TRSQLTest() throws SQLException {
>     username="blahblahblah";
>     password="blahblahblah";
>     dbURL = "jdbc:oracle:thin:@(DESCRIPTION =(ADDRESS =(COMMUNITY =
> world)(PROTOCOL = TCP)(Host = prodtisrv11)(Port = 1521))(CONNECT_DATA =
(SID
> = orc1)))";
>     DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());
>     conn = DriverManager.getConnection(dbURL, username, password);
>   }
>
>   public ResultSet getTables() throws SQLException {
>     Statement stmt = conn.createStatement();
>     return stmt.executeQuery("select table_name from user_tables");
>   }
>
>   public ResultSet getTableDesc(String tableName) throws SQLException {
>     Statement stmt = conn.createStatement();
>     return stmt.executeQuery("select column_name from user_tab_columns
where
> table_name = '" + tableName + "'");
>   }
> }
>
>
> ******** TestMe.java
> import TRSQLTest.*;
> import java.sql.*;
>
> class TestMe {
>   public static void main (String args[]) throws SQLException {
>     TRSQLTest t = new TRSQLTest();
>     ResultSet rs = t.getTables();
>     while (rs.next()) {
>       String tableName = rs.getString(1);
>       System.out.println (tableName);
>       ResultSet rss = t.getTableDesc(tableName);
>       while (rss.next()) {
>         String fieldName = rss.getString(1);
>         System.out.println ("     " + fieldName);
>       }
>
>     }
>   }
> }
>
> Jonathan Halterman
> Track Record Webification Project
> Compuware Corporation
> (248) 737-7300 x18745
>
> Do justly, Love mercy, Walk humbly  - Micah 6:8
>
>
===========================================================================
> 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

Reply via email to