struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sławek Tuleja <tu...@wp.pl>
Subject login and password problem
Date Wed, 10 Aug 2005 18:28:10 GMT
Hello

1.) I have this in struts-config.xml:

-----------------------------------------------------------------------
<data-sources>
     <data-source
       type="org.apache.commons.dbcp.BasicDataSource" >
       <set-property property="driverClassName"
         value="com.microsoft.jdbc.sqlserver.SQLServerDriver" />
       <set-property property="url"
         value="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=legra"  
/>
       <set-property property="username"
         value="myUserName" />
       <set-property property="password"
         value="myPassword" />
     </data-source>
</data-sources>
------------------------------------------------------------------------

2.) but I want to give username and password in java file

------------------------------------------------------------------------
public class LoginJDBC {

     public static String getStatusRoli(String UserName, String Password,
             DataSource dataSource)
             throws Exception {

         Connection conn = null;
         Statement stmt = null;
         ResultSet rs = null;
         String status = null;
         try {

		//------------------------------------
		//HOW TO INSERT THIS NEW CODE IN HERE?
		//------------------------------------

             conn = dataSource.getConnection();
             stmt = conn.createStatement();
             rs =
                     stmt.executeQuery("SELECT status_roli FROM  
legra_uzytkownicy WHERE "
                     + "UserName = '" + UserName + "' AND " + "Password =  
'" + Password + "'"
                     + " AND usuniete='nie' AND status_konta='aktywne'");

             if ( rs.next() ) {
                 status = rs.getString("status_roli");
             } else {
                 throw new Exception(UserName + " nie znaleziono!");
             }
         } finally {
             if ( rs != null ) {rs.close();}
             if ( stmt != null ) {stmt.close();}
             if ( conn != null ) {conn.close();}
         }
         return status;
     }
}
------------------------------------------------------------------------------

3.) How to change struts-config.xml

4.) SUMMARY :
	
	i do not want to link my program with database via struts-config.xml
	i want to link my program with database when i put in the login and the  
password


5.) Could you help me?










-- 
------------------------------------
Sławek Tuleja
ul. Spółdzielców 12/81, Kraków 30-682
tel: (012) 655 50 57
www.tusla.pl
------------------------------------

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message