First: Jdbc-odbc database connection Bridge (need to configure ODBC data source, no download driver required)
class.forname ("Sun.jdbc.odbc.JdbcOdbcDriver");
con=drivermanager.getconnection ("JDBC:ODBC: Data Source Name", "username", "password");
Second: Take advantage of Microsoft-supplied drivers (XP users need to hit SP3 patches and need to download drivers)
class.forname ("Com.microsoft.jdbc.sqlserver.SQLServerDriver");
con=drivermanager.getconnection ("jdbc:microsoft:sqlserver://localhost:1433;databasename= database name", "username", "password");
Third: Using drivers provided by third parties (download driver required)
class.forname ("Net.sourceforge.jtds.jdbc.Driver");
con=drivermanager.getconnection ("jdbc:jtds:sqlserver://localhost:1433/database name; user= user name; password= password");
Fourth: Configure the data source under struts (in fact this is not a type with the top)
<data-sources>
<data-source key= "name of data source in struts" type= "Org.apache.commons.dbcp.BasicDataSource" >
<set-property property= "Driverclassname" value= "Sun.jdbc.odbc.JdbcOdbcDriver"/>
<set-property property= "url" value= "JDBC:ODBC: Data source"/>
<set-property property= "username" value= "username"/>
<set-property property= "password" value= "password"/>
</data-source>
</data-sources>