The datasource must be registered with the application server you are using. First check if its done.
Jitendra ----- Original Message ----- From: "Tanmaya" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, December 27, 2002 5:44 PM Subject: How to connect a database in SQL Server ? 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 -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>