My Java learning road 5: SQL Server database operation

xiaoxiao2021-03-06  93

First install the JSP to access the driver of SQL Server 2000:

Download drivers from Microsoft's website: SQL Server 2000 For JDBC driver, in Google, you can search in Google. Then you must use the three JAR files in the LIB directory in the installation directory:

Msbase.jar, mssqlserver.jar, msutil.jar Copy to Tomcat directory under CommON / lib directory. And set ClassPath. Then restart Tomcat.

<% @ Page info = "Database handler"%> <% @ page import = "java.io. *"%> <% @ page import = "java.util. *"%> <% @ page import = "java.sql. *"%> <% @ page import = "javax.servlet. *"%> <% @ Page Import = "javax.servlet.http. *"%> <% class.forname ("com.microsoft.jdbc.sqlser.sqlserverdriver); string url =" JDBC: Microsoft: SQLServer: // localhost: 1433; databasename = database name "; connection conn = drivermanager.getConnection (URL," User Name "," Password "); Statement Stmt = Conn.createStatement (); string query =" Create Table Coffeees " " (COF_NAME VARCHAR (32), " " Sup_ID Integer, " " Price Float, " " SALES INTEGER, " " Total Integer "; // Execute Stmt.executeUpdate (Query);%>

转载请注明原文地址:https://www.9cbs.com/read-105544.html

New Post(0)