You need to find an appropriate JDBC driver to be able to connect to Microsoft SQL Server using JDBC. Following are the preferred drivers for SQL Server:
Download JTDS
jTDS is an open source JDBC 3.0 driver for Microsoft SQL Server (6.5, 7, 2000 and 2005). Place jar file into your application classpath. java.sql package along with above driver helps connecting to database.
Microsoft SQL Server 2000 Driver for JDBC is a Type 4 JDBC driver. You need to place the jar files in your CLASSPATH variable.
The example below shows how to make a connection to Microsoft SQL Server 2000 using jTDS driver:
import java.sql.*;
public class testConnection
{
public static void main(String[] args)
{
DB db = new DB();
db.dbConnect(
"jdbc:jtds:sqlserver://localhost:1433/tempdb","sa","");
}
}
class DB
{
public DB() {}
public voidn dbConnect(String db_connect_string,
String db_userid, String db_password)
{
try
{
Class.forName("net.sourceforge.jtds.jdbc.Driver");
Connection conn = DriverManager.getConnection(
db_connect_string, db_userid, db_password);
System.out.println("connected");
}
catch (Exception e)
{
e.printStackTrace();
}
}
};
Features from MVC2 vs MVC3 vs MVC4 vs MVC5 vs MVC6
-
*MVC 2 *
- Customer Side Validation
- Templated Helpers
- Regions
- Nonconcurrent Controllers
- Html.ValidationSummary Helper Method
...
7 years ago
0 comments:
Post a Comment