I created a JDBC resource called "jdbc/gms" under SUN JSAS admin. I am trying SQL query using JSTL tag in a JSP page as follows.
<sql:query var="learning" dataSource="jdbc/gms">
I am getting the error as DataSource invalid: "java.sql.SQLException: No suitable driver".
Instead, If I use the following code it is working properly.
Connection connection = null;
InitialContext ctx = new InitialContext();
DataSource ds = (DataSource) ctx.lookup("jdbc/gms");
Statement stmt = connection.createStatement();
String sqlquery="My Query";
ResultSet rs = stmt.executeQuery(sqlquery);
I am not sure why JSTL SQL Query is not working. Please help.
Have you tried putting the jdbc driver in your ServletContext WEB-INF/lib directory? If its not there?, you might try putting it there. If it is there -- does the driver exist in the server configuration. If it exists in both your Context config and server config -- you might try removing it from your ServletContext.
I am not using any Servlet Context. I do have the JDBC driver files in WEB-INF/lib directory. I created 'JDBC' resource with JNDI name under the 'Sun JSAS Administrator'. I was able to use the JDBC resource (without any other extra settings) with the native Java code as I have mentioned in my previous thread. But, not with JSTL. JSTL is not recognizing the JDBC data source I have created on the Server.
I'm not following you... If your not using a servlet context -- where are you running JSP page that uses the JSP Standard Tag Library? I'm with you in that you configured your JDBC Resource through JNDI using Sun's Application Server Admin Console. It's been awhile since I fooled with JSAS so please bear with me.
Did you configure your Http Services to use the resource? Specifically - did you make sure your virtual server property allowLinking is set to true. It will be in your sun-web.xml file and will look something like this
You might also check to make sure the jsp your calling is in the same domain that you set your JDBC resource in. Other than that -- I don't know what to tell you.
<property name="allowLinking" value="true"/>
I am confused. I thought if I set the data source on Server, I can use it without any other extra settings. Can you point to me of any examples using datasource (configured on server) in JSTL sql:query.
Sure, take a look at these for starters
JSAS - Configuring the Http Services
JSAS - More About JDBC Resources
JSAS - Application Server Configuration
I included the App Server Config link in this so you see how to reference the domain(s) you have set up. I hope this helps
You can generally speaking; however, that does not mean you still don't have more configuration to do. That is why you need to make sure your Http Service is properly set up and that the JSP page you are using the JSTL call for the datasource is infact running in the same instance as is the JDBC Resource. By default, allowLinking is set to true but you can turn that off. If you did not turn it off, then it could very well mean your not running the jsp in the right place... You can have more than one
I am confused. I thought if I set the data source on Server, I can use it without any other extra settings.
Last edited by smcneill; 05-03-2006 at 04:41 PM.
By premartha in forum ASP.NET
Last Post: 11-19-2005, 02:13 AM
Last Post: 03-12-2002, 05:40 AM
By justin in forum VB Classic
Last Post: 04-21-2000, 05:24 PM
By Justin M in forum VB Classic
Last Post: 04-19-2000, 01:19 PM
By Nick Koszykowski in forum VB Classic
Last Post: 03-28-2000, 03:21 PM
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center