I am getting folloing error while inserting into a access database.
---------------------------------------------------------------
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:4246)
at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(JdbcOdbc.java:1172)
at sun.jdbc.odbc.JdbcOdbcStatement.execute(JdbcOdbcStatement.java:206)
at sun.jdbc.odbc.JdbcOdbcStatement.executeUpdate(JdbcOdbcStatement.java:
163)
at InsertArticle.doPost(InsertArticle.java, Compiled Code)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:4
04)
at org.apache.tomcat.core.Handler.service(Handler.java:286)
at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372
)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.
java:797)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:743
)
at org.apache.tomcat.service.http.HttpConnectionHandler.processConnectio
n(HttpConnectionHandler.java:210)
at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java,
Compiled Code)
at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java
, Compiled Code)
at java.lang.Thread.run(Thread.java:479)
----------------------------------------------------------------
Help me to do it.
My Code is below.
thanks.
Arun
__________________________________________________________
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.sql.*;
import java.util.Date;
public class InsertArticle extends HttpServlet{
// Data base connection
Connection dbCon;
// establish a connection and share it across all request
public void init(ServletConfig config) throws ServletException
{
super.init(config);
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
dbCon=DriverManager.getConnection("jdbc
dbc:CDGArticle");
}
catch (ClassNotFoundException e)
{
System.out.println("JDBC - ODBC Bridge not found");
return;
//catch1 closed
}
catch (SQLException e)
{
System.out.println("SQL exception thrown init");
return;
// catch2 closed
}
//init closed
}
// caaling doGet to process GET request
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException,IOException
{
try
{
String authorName=request.getParameter("authorName");
String subject=request.getParameter("subject");
String message=request.getParameter("message");
//int i=0;
response.setContentType("text/html");//retuns html
//handle output Stream
PrintWriter out=response.getWriter();
String query = "select authorName, subject, message from CDGKnowledgeHub ";
String query1="insert into CDGKnowledgeHub"+ "values ( 'authorName' + ' subject' +'message')";
Statement stat=dbCon.createStatement();
//int visitor1=
stat.executeUpdate(query1);
ResultSet visitor=stat.executeQuery(query1);
while (visitor.next()) {
String a = visitor.getString(authorName);
String s = visitor.getString(subject);
String m = visitor.getString(message);
System.out.println(a+"\n"+ s+ "\n" + " " + m);
}
stat.close();
dbCon.close();
/*if (visitor1!= 0)
{
dbCon.commit();
//int intMsg = m.sendMessage();
out.println("Thanks "+authorName+". Your change request has been sent to Corporate Intranet Group.");
}//if closed
else
{
dbCon.rollback();
out.println("Kindly try again, the transaction could not be executed");
out.println("<a href=javascript:history.back(); > Back </a> ");
} // else closed*/
}
catch (Exception e)
{e.printStackTrace();
}
//doGet Closed
}
public String getServletInfo()
{
return "CDGArticle servlet";
}
//DisplayArticle closed
}
_________________________________________________________________
------------------