Dolfandave Uyemura

Ranch Hand
+ Follow
since Jun 11, 2002
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Dolfandave Uyemura

Yes, Simon, the size of the dataset would impact your decision to use a relational database software. That being said 1400 records is tiny by database standards. You are also talking about breaking the data in a relational way by student's personal information and performance but that is really just two more objects. For something like that I would definitely use something FREE. That would narrow the list down to MS Access or MySQL. I am not sure that I would go to all that much trouble for such a small dataset w/ all due respect unless you really want to learn SQL.

Good luck.

ddave
I am a Database Developer with about five years experience using SQL with SQL Server 2000. If you are just in need of something to keep track of a classroom then you don't need SQL. SQL is a wonderful thing to learn but if that is the purpose then it is definitely overkill. One of the many great things about SQL is that the concepts are transferable for the most part among the vendors meaning that if you learn the SQL flavor for SQL Server you can apply it to Oracle for the most part or Sybase or MySQL or Access or DB2. I always encourage people to at least take a look at it if looking into a tech career. If you really master it, your skills can transfer between these vendors and you will be a candidate to work in various fields, ie Healthcare, Financial, etc. In a lot of ways data is data and the concepts overlap. But to really be good w/ SQL you have to be devoted to it. It is great for working on large datasets and due to it's relational nature these databases can be broken down into various objects.

ddave
Ok,
So what are the steps necessary to create and upload this file?
ddave
My shared server has a prefix to database names in the format of:
domainname_com_-_databasename
exactly in this format. When I create/use a .java file and compile it to a .class file, the test environment on my standalone computer at home is just the "databasename". Should I be using just this databasename or should I include the entire prefix including underscores and hyphen when I compile? The next step of course would be to upload it to the appropriate directory and attempt to run it. I am using JSP, Java, and the MySQL database that comes on the shared server.
ddave
Hi Paul,
I am interested in learning about Web Services. For a beginner would you say that the Java Web Server documentation at this site: http://java.sun.com/webservices/docs/1.1/tutorial/doc/index.html would be a good start?
Thanks and God Bless.
Dolfandave
17 years ago
"The classpath issue you're having seems to reside with the servlet container. While the .wrox packages may be in your system classpath (allowing you to compile the relevant class files and deploy your app), the servlet container itself has its own classpath, which it uses when compiling JSP's. As a result, you should add any necessary .jar files to your application's WEB-INF/lib directory. Any jar files in this directory are automatically added to the servlet container's classpath on application startup. The .jar file you're missing is the one that contains the "com.wrox.databases" classes"
So Brian,
Where do you get these .jar files?
ddave
17 years ago
JSP
Also,
I forgot to mention that I copied the Book.class file after I compiled Book.java into the lib file adjacent to the path ....com\wrox\database\Book.java FWIW.
ddave
17 years ago
JSP
I continue to get the same error. This is getting frustrating. I compiled and ran a few scripts that interact with a MySQL database per Beginning JSP Web Development by Wrox Press. I have no problem interacting with the database but when I try to go to the localhost site (http://localhost:8080/begjsp-ch16/booklist.jsp), I get the errors I initially posted. The booklist.jsp file looks like this:
<%@ page language="java"
import="java.sql.*, java.io.*, java.util.*, com.wrox.databases.*"
errorPage="error.jsp" %>
<jsp:useBean id="book" class="com.wrox.databases.Books" />
<html>
<head>
<title> Wrox Press Ltd. </title>
</head>
<body>
<h1> Wrox Press Ltd.</h1>
<h2> List of Books </h2>
<a href="newbook.jsp"><b>Add More Books</b></a>
<form action="delete.jsp" method="post">
<table border="1">
<tr>
<td><b>ID:</b></td>
<td><B>Title:</b></td>
<td><B>Price:</b></td>
</tr>
<%
book.connect();
ResultSet rs = book.viewBooks();
while (rs.next()) {
%>
<tr>
<td>
<input type="checkbox" name="pkey"
value="<%= rs.getString("Title_ID") %>" />
</td>
<td><%= rs.getString("Title") %></td>
<td><%= rs.getString("Price") %></td>
</tr>
<%
}
%>
</table><br />
Check books for deletion.<BR>
<input type="submit" value="Delete All Checked Books">
</form>
<% book.disconnect(); %>
</body>
</html>
===================================
and is in this file: c:\jakarta-tomcat-4.1.24\webapps\begjsp-ch16
The Books.java application is in c:\jakarta-tomcat-4.1.24\webapps\begjsp-ch16\web-inf\classes\com\wrox\databases per very specific instructions from the text.
Books.java is as follows:
package com.wrox.databases;
import java.sql.*;
import java.util.*;
public class Books {
String error;
Connection con;
public Books() { }
public void connect() throws ClassNotFoundException,
SQLException,
Exception {
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
con = DriverManager.getConnection(
"jdbc:mysql://localhost/Wrox ?user=root&password=");
} catch (ClassNotFoundException cnfe) {
error = "ClassNotFoundException: Could not locate DB driver.";
throw new ClassNotFoundException(error);
} catch (SQLException cnfe) {
error = "SQLException: Could not connect to database.";
throw new SQLException(error);
} catch (Exception e) {
error = "Exception: An unknown error occurred while connecting " +
"to database.";
throw new Exception(error);
}
}
public void disconnect() throws SQLException {
try {
if ( con != null ) {
con.close();
}
} catch (SQLException sqle) {
error = ("SQLException: Unable to close the database connection.");
throw new SQLException(error);
}
}
public ResultSet viewBooks() throws SQLException, Exception {
ResultSet rs = null;
try {
String queryString = ("SELECT * FROM Book;");
Statement stmt = con.createStatement();
rs = stmt.executeQuery(queryString);
} catch (SQLException sqle) {
error = "SQLException: Could not execute the query.";
throw new SQLException(error);
} catch (Exception e) {
error = "An exception occured while retrieving books.";
throw new Exception(error);
}
return rs;
}
public void addBooks(int id, String title, float price, int cid)
throws SQLException, Exception {
if (con != null) {
try {
PreparedStatement updatebooks;
updatebooks = con.prepareStatement(
"insert into Book values(?, ?, ?, ?);");
updatebooks.setInt(1, id);
updatebooks.setString(2, title);
updatebooks.setInt(3, cid);
updatebooks.setFloat(4, price);
updatebooks.execute();
} catch (SQLException sqle) {
error = "SQLException: update failed, possible duplicate entry";
throw new SQLException(error);
}
} else {
error = "Exception: Connection to database was lost.";
throw new Exception(error);
}
}
public void removeBooks(String [] pkeys) throws SQLException, Exception {
if (con != null) {
try {
PreparedStatement delete;
delete = con.prepareStatement("DELETE FROM Book WHERE Title_ID=?;");
for (int i = 0; i < pkeys.length; i++) {
delete.setInt(1, Integer.parseInt(pkeys[i]));
delete.execute();
}
} catch (SQLException sqle) {
error = "SQLException: update failed, possible duplicate entry";
throw new SQLException(error);
} catch (Exception e) {
error = "An exception occured while deleting books.";
throw new Exception(error);
}
} else {
error = "Exception: Connection to database was lost.";
throw new Exception(error);
}
}
}
==============================
Thanks again,
ddave
17 years ago
JSP
Hi Uma,
"Do you have the package com.wrox.databases in the classpath?? Just check if you have put the classes from com.wrox.databases package in the "lib" folder of your application folder."
I don't believe I have done this. How do you do this? Is it after I compile the Java application? It sounds like I need to copy the classes and NOT an issue w/ my Autoexec.bat file? Please confirm and thank you.
ddave
17 years ago
JSP
Hi all,
I am getting the error below when I run a JSP ap to add books to an inventory:
Thanks again to all.
ddave
HTTP Status 500 -
--------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: -1 in the jsp file: null
Generated servlet error:
[javac] Since fork is true, ignoring compiler setting.
[javac] Compiling 1 source file
[javac] Since fork is true, ignoring compiler setting.
[javac] C:\jakarta-tomcat-4.1.24\work\Standalone\localhost\begjsp-ch16\booklist_jsp.java:10: package com.wrox.databases does not exist
[javac] import com.wrox.databases.*;
[javac] ^
[javac] C:\jakarta-tomcat-4.1.24\work\Standalone\localhost\begjsp-ch16\booklist_jsp.java:46: package com.wrox.databases does not exist
[javac] com.wrox.databases.Books book = null;
[javac] ^
[javac] C:\jakarta-tomcat-4.1.24\work\Standalone\localhost\begjsp-ch16\booklist_jsp.java:48: package com.wrox.databases does not exist
[javac] book = (com.wrox.databases.Books) pageContext.getAttribute("book", PageContext.PAGE_SCOPE);
[javac] ^
[javac] C:\jakarta-tomcat-4.1.24\work\Standalone\localhost\begjsp-ch16\booklist_jsp.java:51: package com.wrox.databases does not exist
[javac] book = (com.wrox.databases.Books) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "com.wrox.databases.Books");
[javac] ^
[javac] 4 errors
at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:130)
at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:293)
at org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:353)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:370)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:473)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:190)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:594)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
at java.lang.Thread.run(Thread.java:536)
17 years ago
JSP
Thanks, Tim.
Hope your employment status changes in a positive manner.
Dave
17 years ago
JSP
I am new to doing projects and was wondering if I have clients who are remote what are the considerations of creating a database driven website? One of my recent clients was in Georgia (and I am in California) but they just needed a static website on a shared server. They paid for the account and just handed me the password so to speak. Is this standard practice? I just wanted to know if I am missing something.
What if they have their own server? Would it be inappropriate for me to have them download Java, Tomcat, and MySQL? That seems like a lot to ask of some IT challenged clients.
I feel comfortable working with MySQL, JSP, Java, and HTML so if I do go ahead with such endeavors I will obviously recommend shared hosts with these features (JSP and MySQL).
Thanks for any feedback.
Dave
17 years ago
JSP
Still not holding form, here is a link I created and uploaded.

http://www.geocities.com/dave_uyemura/javaranch.html

Dolfandave
The last post didn't hold my indents. I have tried again below. Also, use a font like Courier New that is "monospaced font" so each character is exactly one space and always use spaces instead of tabbing. Tabs represent only ONE space so that can really throw you off.
code:
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
Dolfandave

Code tags will help you.-- MdQ
[ November 15, 2003: Message edited by: Marilyn de Queiroz ]
I have done some T-SQL in a data migration project. I think the indentation was something like:
code:
--------------------------------------------------------------------------------
SELECT foo, bar
FROM baz, bat
WHERE yuck = yamma mamma AND
chuck = bananarama;
LEFT OUTER JOIN

SELECT foo, bar
FROM baz, bat
WHERE chuck = yamma mamma
AND (baz.yuck = bananarama OR bat.yuck = yamma mamma);
--------------------------------------------------------------------------------
Good Luck,
Dolfandave