attempting datasource jstl sql operations, , won't connect.
in web.xml
:
<context-param> <param-name>databasejndi</param-name> <param-value>jdbc/testds</param-value> </context-param>
what i'm attempting in jsp file:
<sql:setdatasource datasource = "jdbc/testds"/>
i'm attempting , failing in order avoid hard-coding database credentials page. database running, don't know enough jstl tackle on own right now.
it complaining driver, have used same design servlets without specifying driver access database.
any insight issue? knowing luck it's simple.
using initparam
can context parameters.
create context-params
in web.xml
database connection properties:
<context-param> <param-name>driverclass</param-name> <param-value>com.mysql.jdbc.driver</param-value> </context-param> <context-param> <param-name>connectionurl</param-name> <param-value>jdbc:mysql://localhost/dbname</param-value> </context-param> <context-param> <param-name>username</param-name> <param-value>foo</param-value> </context-param> <context-param> <param-name>password</param-name> <param-value>bar</param-value> </context-param>
in jsp use
<sql:setdatasource var="datasource" driver="${initparam['driverclass']}" url="${initparam['connectionurl']}" user="${initparam['username']}" password="${initparam['password']}" />
Comments
Post a Comment