DataSource invalid


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 6 of 6

Thread: DataSource invalid

  1. #1
    Join Date
    May 2006
    Posts
    3

    DataSource invalid

    Hi,

    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">
    Query
    </sql:query>

    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");
    connection=ds.getConnection();
    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.

  2. #2
    Join Date
    May 2006
    Posts
    23
    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.

  3. #3
    Join Date
    May 2006
    Posts
    3
    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.

  4. #4
    Join Date
    May 2006
    Posts
    23
    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

    Code:
    <sun-web-app>
      <property name="allowLinking" value="true"/>
    </sun-web-app>
    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.

  5. #5
    Join Date
    May 2006
    Posts
    3
    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.

  6. #6
    Join Date
    May 2006
    Posts
    23
    Sure, take a look at these for starters

    JSAS - Configuring the Http Services
    http://docs.sun.com/source/819-0076/httpservice.html

    JSAS - More About JDBC Resources
    http://docs.sun.com/source/819-0076/jdbc.html

    JSAS - Application Server Configuration
    http://docs.sun.com/source/819-0076/...html#wp1051891

    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

    I am confused. I thought if I set the data source on Server, I can use it without any other extra settings.
    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
    Last edited by smcneill; 05-03-2006 at 04:41 PM.

Similar Threads

  1. Replies: 1
    Last Post: 11-19-2005, 02:13 AM
  2. Array As Datasource of DataGrid
    By Arun in forum .NET
    Replies: 1
    Last Post: 03-12-2002, 05:40 AM
  3. DataSource GPF
    By justin in forum VB Classic
    Replies: 0
    Last Post: 04-21-2000, 05:24 PM
  4. Error message when setting DataSource property
    By Justin M in forum VB Classic
    Replies: 0
    Last Post: 04-19-2000, 01:19 PM
  5. Re: How to set the DataSource to UserControl
    By Nick Koszykowski in forum VB Classic
    Replies: 0
    Last Post: 03-28-2000, 03:21 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center