[opencms-dev] Addressing external database from JSP

Björn Schlueter bschlueter at lenord.de
Fri Apr 30 10:42:00 CEST 2004


Hello there,

as a newbie I am stuck with this little problem.
I am trying to access from opencms an external datebase (namely a ms sql 2000 server).
I know I should use a servlet to access that db, but right know i want to use a jsp as a shortcut.

This ist what my code looks like:

<html>
<body>
<%@ page 
import = "java.io.*"
import = "java.lang.*"
import = "java.sql.*"
%>

<%!
   String sDbDrv = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
   String sDbUrl = "jdbc:microsoft:sqlserver://server/bla";
   String sSql = "SELECT * from Example";
   
   public void jspInit() 
       {
       Class.forName(sDbDrv);
       Connection cn = DriverManager.getConnection(sDbUrl, "bla", "bla");
       }

   Statement st = cn.createStatement();
   ResultSet rs = st.executeQuery(sSql);

   ResultSetMetaData meta = rs.getMetaData();
   out.println("Got results:");

            while
              (rs.next() == true)
              {
                // Which Column?
                out.println("Working Title: ");
                String a = rs.getString("P_TITEL");
                out.print(a);

                 //Which Column?
                out.print("Projektziel: ");
                String b = rs.getString("P_ZIEL");
                out.print(b);
}
%>
</body>
</html>


I really don't know, why OpenCMS does not want to compile that jsp. 

I get the following  messages:

javax.servlet.ServletException: Resource loader error in file '/testdb.jsp'

Root cause:
org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: -1 in the jsp file: null

I am pretty much helpless right know. I couldn't find help at google or relevant java forums!

Can somone of you give me a hint?

Thanks

Björn





More information about the opencms-dev mailing list