File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

I have no idea!!!! Help.

 
yasuo
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3340
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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+"')");
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic