jsp Simple Connection Method of SQL Server2000 Database
- 2021-07-09 08:59:39
- OfStack
In this paper, the simple connection method of jsp to SQL Server 2000 database is illustrated. Share it for your reference. The details are as follows:
package util;
import java.sql.Connection;
import java.sql.DriverManager;
public class ConnDB {
public static String driver="com.microsoft.jdbc.sqlserver.SQLServerDriver";
public static String url="jdbc:microsoft:sqlserver://localhost:1433;databaseName=temp";
public static String username="sa";
public static String password="";
public static Connection con=null;
public static Connection getConnection()
{
try {
Class.forName(driver);
con=DriverManager.getConnection(url,username,password);
System.err.println(" Link Successful ");
} catch (Exception e) {
e.printStackTrace();
}
return con;
}
public static void main(String[] args) {
ConnDB.getConnection();
}
}
I hope this article is helpful to everyone's JSP programming.