Following may help

<resource-ref>
       <res-ref-name>jdbc/test</res-ref-name>
       <res-type>javax.sql.DataSource</res-type>
       <init-param driver-name="com.inet.tds.TdsDriver"/>
       <init-param url="jdbc:inetdae7:VARSHA:1433?database=artimus"/>
       <init-param user="artimus"/>
       <init-param password="artimus"/>
</resource-ref>







From: "Tanmaya" <[EMAIL PROTECTED]>
Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Subject: How to connect a database in SQL Server ?
Date: Fri, 27 Dec 2002 17:44:16 +0530

Hi All,

I am new to Struts.Kindly anyone let me know, what I should do, to connect a database in SQL Server.I have the struts-config.xml file where I defined the datasource parameters...

<data-sources>
<data-source>
<set-property property="autoCommit"
value="false"/>
<set-property property="description"
value="Example Data Source Configuration"/>
<set-property property="driverClass"
value="com.microsoft.jdbc.sqlserver.SQLServerDriver"/>
<set-property property="maxCount"
value="4"/>
<set-property property="minCount"
value="2"/>
<set-property property="password"
value="taapplication"/>
<set-property property="url"
value="jdbc:microsoft:sqlserver://tanmaya:1433"/>
<set-property property="user"
value="taapplication"/>
</data-source>
</data-sources>

In the Action class,I tried to access the database in perform method as follows...

public ActionForward perform(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) {

Connection connection = null;
DataSource dataSource = null;
Statement statement = null;
ResultSet resultSet = null;
try {
dataSource = servlet.findDataSource(null);
connection = dataSource.getConnection();
statement = connection.createStatement();
resultSet = statement.executeQuery("select * from team_shift");
System.out.println("\n\n AFTER EXEcuting the query.....");
while (resultSet.next())
{
System.out.println("Shift:"+resultSet.getString("shift_code"));
}
resultSet.close(); // just a test
} catch (SQLException sqle) {
getServlet().log("Connection.process", sqle);
} finally {

try {
connection.close();
} catch (SQLException e) {
getServlet().log("Connection.close", e);
}
}


In this way I am able to connect to the default database of SQL Server(i.e. master) database successfully.I wanna access to my own database.How can I achive it ??Where should I mention my database name ?? I tried by mentioning my database name in the url property as follow :
set-property property="url" value="jdbc:microsoft:sqlserver://tanmaya:1433/TAProd"/>

But in this way I am getting error (org.apache.jasper.JasperException: Cannot find ActionMappings or ActionFormBeans collection) while tried to access the jsp itself.

Please help me to knock this problem down.

Thanks in advance,
Tanmaya

_________________________________________________________________
Add photos to your e-mail with MSN 8. Get 2 months FREE*. http://join.msn.com/?page=features/featuredemail


--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to