MS access through JSP

hai

I am trying to access MS access database through JSP

My code:

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

java.sql.Connection connection = java.sql.DriverManager.getConnection("jdbc dbc:bill");

java.sql.Statement statement = connection.createStatement();

Enumeration parameters = request.getParameterNames();

if(parameters.hasMoreElements()) {

String lastvalue = request.getParameter("lastParam");

String firstvalue = request.getParameter("fisrtParam");

String amountvalue = request.getParameter("amount");

statement.executableUpdate(

"INSERT INTO tellist (\"Last Name\", \"First Name\", \"amou\") VALUES

('"+lastvalue+"','"+firstvalue+"','"+amountvalue+"')");

}

java.sql.ResultSet columns = statement.executeQuery(

"SELECT * FROM list");

while(columns.next()) {

String last = columns.getString("Last Name");

String first = columns.getSting("First Name");

String phone = columns.getString("amount");

< tr> < td> last < /td>

< td> first < /td>

< td> phone < /td>

< /tr>

}

I am getting the following error

pls let me know the solution why it si happening

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\", \"amount\") VALUES

^

D:\jakarta-tomcat-3.2.3\work\localhost_8080\_0002ftak_0002ejsptak_jsp_0.java:72: ')' expected.

('"+lastvalue+"','"+firstvalue+"','"+amountvalue+"')");

^

D:\jakarta-tomcat-3.2.3\work\localhost_8080\_0002ftak_0002ejsptak_jsp_0.java:72: Invalid character constant.

('"+lastvalue+"','"+firstvalue+"','"+amountvalue+"')");

^

D:\jakarta-tomcat-3.2.3\work\localhost_8080\_0002ftak_0002ejsptak_jsp_0.java:72: Invalid character constant.

('"+lastvalue+"','"+firstvalue+"','"+amountvalue+"')");

^

D:\jakarta-tomcat-3.2.3\work\localhost_8080\_0002ftak_0002ejsptak_jsp_0.java:72: Invalid character constant.

('"+lastvalue+"','"+firstvalue+"','"+amountvalue+"')");

^

D:\jakarta-tomcat-3.2.3\work\localhost_8080\_0002ftak_0002ejsptak_jsp_0.java:72: String not terminated at end of line.

('"+lastvalue+"','"+firstvalue+"','"+amountvalue+"')");

thanks

[2562 byte] By [herrnik] at [2007-9-26 5:38:43]
# 1

Hi,

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\", \"amount\") VALUES

('"+lastvalue+"','"+firstvalue+"','"+amountvalue+"')");

to be one String but, you have 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 follows the above.

"INSERT INTO tellist (\"Last Name\", \"First Name\", \"amount\") VALUES " +

"('"+lastvalue+"','"+firstvalue+"','"+amountvalue+"')");

Hope this will help you.

Anil.

Developer Techncial Support

Sun Microsystems

http://ww.sun.com/developers/support

ramanil_indts at 2007-7-1 13:51:56 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...