jQuery in Action, 2nd edition*
The moose likes JDBC and the fly likes I have no idea!!!! Help. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "I have no idea!!!! Help." Watch "I have no idea!!!! Help." New topic
Author

I have no idea!!!! Help.

yasuo
Greenhorn

Joined: Jul 24, 2001
Posts: 1
I tried to access to the MS access database by the following code (JSP file).
Please let me know how to solve this problem.
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
java.sql.Connection connection = java.sql.DriverManager.getConnection("jdbc dbc:telephone");

java.sql.Statement statement = connection.createStatement();
Enumeration parameters = request.getParameterNames();
if(parameters.hasMoreElements()) {
String lastvalue = request.getParameter("lastParam");
String firstvalue = request.getParameter("fisrtParam");
String phonevalue = request.getParameter("phoneParam");
statement.executableUpdate(
"INSERT INTO tellist (\"Last Name\", \"First Name\", \"Phone\") VALUES
('"+lastvalue+"','"+firstvalue+"','"+phonevalue+"')");
}
java.sql.ResultSet columns = statement.executeQuery(
"SELECT * FROM tellist");
while(columns.next()) {
String last = columns.getString("Last Name");
String first = columns.getSting("First Name");
String phone = columns.getString("Phone");
< tr> < td> last < /td>
< td> first < /td>
< td> phone < /td>
< /tr>

}
However, the error message I got is the follwing.
I do not kow even why I got this message. It seems that it does not recognize the driver.
org.apache.jasper.JasperException: Unable to compile class for JSPD:\jakarta-tomcat-3.2.3\work\localhost_8080\_0002ftak_0002ejsptak_jsp_0.java:71: String not terminated at end of line.
"INSERT INTO tellist (\"Last Name\", \"First Name\", \"Phone\") VALUES
^
D:\jakarta-tomcat-3.2.3\work\localhost_8080\_0002ftak_0002ejsptak_jsp_0.java:72: ')' expected.
('"+lastvalue+"','"+firstvalue+"','"+phonevalue+"')");
^
D:\jakarta-tomcat-3.2.3\work\localhost_8080\_0002ftak_0002ejsptak_jsp_0.java:72: Invalid character constant.
('"+lastvalue+"','"+firstvalue+"','"+phonevalue+"')");
^
D:\jakarta-tomcat-3.2.3\work\localhost_8080\_0002ftak_0002ejsptak_jsp_0.java:72: Invalid character constant.
('"+lastvalue+"','"+firstvalue+"','"+phonevalue+"')");
^
D:\jakarta-tomcat-3.2.3\work\localhost_8080\_0002ftak_0002ejsptak_jsp_0.java:72: Invalid character constant.
('"+lastvalue+"','"+firstvalue+"','"+phonevalue+"')");
^
D:\jakarta-tomcat-3.2.3\work\localhost_8080\_0002ftak_0002ejsptak_jsp_0.java:72: String not terminated at end of line.
('"+lastvalue+"','"+firstvalue+"','"+phonevalue+"')");

[This message has been edited by Carl Trusiak (edited July 24, 2001).]
The html embedded in his code really caused some problems with UBB. I removed the scrpting indicators(They where right) and modified the html tags with a space after the < to allow things to appear right.
[This message has been edited by Carl Trusiak (edited July 24, 2001).]
Carl Trusiak
Sheriff

Joined: Jun 13, 2000
Posts: 3340
JavaRanch has a Naming Policy Please reregister with a proper name.

Scriptlet code inside a JSP page still has to follow the same rules as java code. Your intending for
"INSERT INTO tellist (\"Last Name\", \"First Name\", \"Phone\") VALUES
('"+lastvalue+"','"+firstvalue+"','"+phonevalue+"')");
to be one String but, you've run it on two lines. If you do this, you have to end the String on the first line and added the String from the second line. I think the rest of the exceptions are a cascade.
"INSERT INTO tellist (\"Last Name\", \"First Name\", \"Phone\") VALUES " +
"('"+lastvalue+"','"+firstvalue+"','"+phonevalue+"')");

I Hope This Helps
Carl Trusiak, SCJP2, SCWCD
 
wood burning stoves
 
subject: I have no idea!!!! Help.
 
Similar Threads
Internal Servlet Error with JSP + Tomcat 3.2.3
error 500 in JSP
invalid character constant
Error Message
jsp forward page