Hello,
Here is my “configuration” : Windows Server 2003, BO XI R2, Apache/Tomcat, SQL Server 2005.
I put sqljdbc.jar into my tomcat/lib directory and put this directory into my classpath environnement variable.
Here is what I wanna do : Displaying, on login page, a date which is in my SQL Server database.
I modify logon.jsp in order to run the appropriate query, I follow examples found on the web.
This is my code (file logon.jsp) :
(in bold the code I added to display the date)
[...]
<%@ page language="java" contentType="text/html;charset=utf-8" %>
<%@ page import="com.crystaldecisions.ePortfolio.framework.common.CEClientConstants,
com.crystaldecisions.ePortfolio.framework.common.UserSettings,
com.crystaldecisions.webapp.CEConstants,
java.util.Locale" %>
[b]<%@ page import= "java.sql.*"%>[/b]
<%@ taglib uri='/WEB-INF/fmt.tld' prefix='fmt' %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri='/WEB-INF/c.tld' prefix='c' %>
<%@ taglib uri='/WEB-INF/c-rt.tld' prefix='c_rt' %>
[b]<%
Connection con = null;
String DT_ALIM= null;
try {
// Load the JDBC driver
String driverName = "com.jdbc.microsoft.sqlserver.SQLServerDriver";
//Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
//Class.forName("com.inet.tds.TdsDriver");
Class.forName(driverName);
// Create a connection to the database
String serverName = "myserver";
String mydatabase = "mybase";
String url = "jdbc:microsoft:sqlserver://" + serverName + "/" + mydatabase;
//String url = "jdbc:inetdae7:myserver:1433?useCursorAlways=true";
// a JDBC url
String username = "myuser";
String password = "mypass";
con = DriverManager.getConnection(url, username,
password);
} catch (ClassNotFoundException e) {
// Could not find the database driver
DT_ALIM="Driver Error";
} catch (SQLException e) {
// Could not connect to the database
DT_ALIM="Database Error";
}
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("SELECT VAL_PARAM FROM DWH_PARAMETRE_VISION WHERE ID_PARAM = 'DT_ALIM'") ;
rs.next();
DT_ALIM=rs.getString(1);
%>[/b]
[...]
[b]<td height="24" width="398">
<div align="center"><font color="#CCCCCC"><span style="font-family:Verdana; font-size:10px; font-weight:normal; color:#A3A3A3; "><font face="Verdana, Arial, Helvetica, sans-serif" font-size:10px><b><span class="texte_gras_fonce"><font color="#000000">Derni&egrave;re
alimentation le :</font></span><br>
</b></font> <b> <font face="Verdana, Arial, Helvetica, sans-serif" size="2">
</font><font color="#000000"><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2"><%= DT_ALIM %></font></b></font></b></span></font></div>
</td>[/b]
The problem is that the page is not working.
When I comment the Statement, ResultSet and assignment (only the last one) lines, the page is displayed “correctly” but DT_ALIM = Driver Error[b] !
Has anyone any idea of what I’m doing badly !!??? :crazy:
Thanks in advance for any help,
[/b]
ausylan (BOB member since 2005-01-10)