新手问个jdbc连接oracle数据库的小问题 求高手指教
oracle驱动包(ojdbc14.jar)已放在lib下
然后我写了一端代码 用于验证登陆操作 代码如下:
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%@page contentType="text/html" pageEncoding="GBK"%>
<%@ page import="java.sql.*"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'login_check.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<center>
<h1>登陆操作</h1>
<hr>
<%!
private final static String DRIVER = "oracle.jdbc.driver.OracleDriver";
private final static String Url="jdbc:Oracle:thin:@127.0.0.1:1521:orcl";
private final static String User="cloudlib";
private final static String Pw="cloudlib";
%>
<%!
Connection conn = null ; // 数据库连接
PreparedStatement pstmt = null ; // 数据库预处理操作
ResultSet rs = null ; // 查询要处理结果集
boolean flag = false ; // 保存标记
String name = null ; // 保存真实姓名
%>
<%
try{
%>
<%
Class.forName(DRIVER) ;
connection conn= DriverManager.getconnection(Url,User,Pw);
String sql = "SELECT name FROM user WHERE userid=? AND password=?" ;
pstmt = conn.prepareStatement(sql) ;
pstmt.setString(1,request.getParameter("id")) ;
pstmt.setString(2,request.getParameter("password")) ;
rs = pstmt.executeQuery() ; // 查询
if(rs.next()){ // 如果有数据,则可以执行
flag = true ; // 表示登陆成功
name = rs.getString(1) ;
}
%>
<%
}catch(Exception e) {
e.printStackTrace() ;
}
finally{
try{
rs.close() ;
pstmt.close() ;
conn.close() ;
} catch(Exception e){}
}
%>
<%
if(flag){ // 登陆成功
%>
<jsp:forward page="login_success.jsp">
<jsp:param name="uname" value="<%=name%>"/>
</jsp:forward>
<%
} else { // 登陆失败
%>
<jsp:forward page="login_failure.jsp"/>
<%
}
%>
</center>
</body>
</html>
这句报错:connection conn= DriverManager.getconnection(Url,User,Pw);
信息为:connection
cannot be resolved to a type
------解决方案--------------------Connection conn= DriverManager.getconnection(Url,User,Pw);
connection 第一个字母大写。
------解决方案--------------------Connection conn= DriverManager.getConnection(Url,User,Pw);
------解决方案--------------------