Jsp simple connection to SQL Server2000 Database method, sqlserver2000
This example describes how to use jsp to connect to the SQL Server database. Share it with you 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 succeeded");} catch (Exception e) {e. printStackTrace ();} return con;} public static void main (String [] args) {ConnDB. getConnection ();}}
I hope this article will help you with JSP program design.