0
私は、データベース接続がコンテキストパラメータとして設定されているデータベースオブジェクトを介して確立することができるデータベースオブジェクトを持って、私の質問SQLデータソース例外
を再投稿しています。
ServletContext s=e.getServletContext();
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/job_portal","root","root");
s.setAttribute("db_connect",con);
私は、データベースを接続し、
<sql:update dataSource="${applicationScope.db_connect}" >
insert into linkedin_table values(?,?)
<sql:param value="${param.Reference_Person}" />
<sql:param value="${param.Reference_Person_Position}" />
</sql:update>
データを格納するためのSQLのtaglibを使用して、私のJSPページでデータベース・オブジェクトを使用していた。しかし、そのあなたのでです例外
javax.servlet.ServletException: javax.servlet.jsp.JspException: 'dataSource' is neither a String nor a javax.sql.DataSource
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:911)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:840)
のTaNxを説明するために、私はそこにあなたのexplanation.isとの違いを理解し、私はJSPでそのDBオブジェクトを使用して接続 – Ramgopal
を確立することができ、他の方法あなたは「shouldn JSP内でDBオブジェクトを使用しないでください。 JSPは要素をレンダリングするためのものです。サーバーにDBロジックを残し、提示する必要のあるデータだけをJSPに渡します。 –