<%
String url= "jdbc:oracle:thin:@数据库机器名或IP:1521:数据库实例名";
Connection con=null;
String user=request.getParameter("userName");
String password=request.getParameter("password");
try
{
Class.forName(forname);
con =DriverManager.getConnection(url,user,password);
out.write("连接成功!");
}
catch(Exception e)
{
e.printStackTrace();
out.write("连接失败!");
}
%>
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class TestOracleConn {
public static void main(String[] args) {
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
//1521为端口名,orcl为oracle提供的服务名
Connection c= DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:orcl","system","sa");
System.out.println("success!");
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
http://www.newasp.net/tech/java/15493.html
最后一步的下载文件不需要下了,一般lib里头有,直接copy过去,配置好了再去运行
和普通java程序连接数据库一样,jdbc
http://zhidao.baidu.com/question/44960693.html?si=1