jsp登入oracle
<body> <% Class.forName("oracle.jdbc.driver.OracleDriver"); Connection conn=null; String user=request.getParameter("userName"); String password=request.getParameter("password"); try { conn =DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:orcl",user,password); out.write("连接成功!"); Statement st = conn.createStatement(); st.close(); //管理连接 conn.close(); } catch (Exception e) { // TODO 自动生成的 catch 块 e.printStackTrace(); } %> </body>
<body> <form name='frm' action='dengru.jsp' method="post"> 用户名:<input type="text" name="userName"> 密码:<input type="password" name="password"> <input type="submit" value="确定"> </form> </body>