First, put the classes12.jar/ojdbc14.jar driver package in the Oracle Installation Directory (D: \ oracle \ product \ 10.2.0 \ db_1 \ jdbc \ lib \) to the tomcat lib directory.
- <% @ Page language ="Java" Import="Java. SQL .*"PageEncoding ="GBK"%>
- <%! String DBDRIVER ="Oracle. jdbc. driver. OracleDriver";
- String DBURL ="Jdbc: oracle: thin: @ localhost: 1521: orcl";
- String USERNAME ="Scott";
- String PASSWORD ="Orcl";
- Connection conn =Null;
- Statement stmt =Null; %>
- <%
- Try{
- // Instantiate the driver
- Class. forName (DBDRIVER );
- Out. println ("The driver has been instantiated! ");
- Conn = DriverManager. getConnection (DBURL, USERNAME, PASSWORD );
- Out. println ("Connected to the database succeeded! ");
- String SQL ="Create table mldntab (name varchar (20 ))";
- Stmt = conn. createStatement ();
- Stmt.exe cuteUpdate (SQL );
- Out. println ("The table has been created !! ");
- }Catch(Exception e ){
- Out. print ("Database operation problems! Table creation failed! "+ E );
- }
- %>