Cool eye

BlogJava 首页 新随笔 联系 聚合 管理
  63 Posts :: 4 Stories :: 3 Comments :: 0 Trackbacks

mysql
drivers=org.gjt.mm.mysql.Driver
logfile=\doc\\lo.txt

mysql.url=jdbc:mysql://localhost/数据库名?useUnicode=true&characterEncoding=8859_1
mysql.maxconn=5
mysql.user=
mysql.password=
mysql.driver=org.gjt.mm.mysql.Driver
mysql.url=jdbc:mysql://218.197.19.113/study?useUnicode=true&characterEncoding=GBK


Oracle
drivers = oracle.jdbc.driver.OracleDriver
url = jdbc:oracle:thin:@localhost:1521:orcl
DB2
drivers = com.ibm.db2.jdbc.app.DB2Driver
url = jdbc:db2://localhost:5000/sample

Informix
drivers = com.informix.jdbc.IfxDriver
url = jdbc:informix-sqli://123.45.67.89:1533/testDB:INFORMIXSERVER=myserver;
user=testuser;password=testpassword


Sql Server7.0/2000
drivers = com.microsoft.jdbc.sqlserver.SQLServerDriver
drivers = sun.jdbc.odbc.JdbcOdbcDriver
url = jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=pubs
url = jdbc:odbc:driver={SQL Server};server=zhl;Database=school

Access
drivers = sun.jdbc.odbc.JdbcOdbcDriver
url = jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=D:\\projects\\demo.mdb

for example:

<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.sql.*"%>
<html>
<body>
<%Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
String url="jdbc:oracle:thin:@localhost:1521:orcl";
//orcl为你的数据库的SID
String user="scott";
String password="tiger";
Connection conn= DriverManager.getConnection(url,user,password);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql="select * from test";
ResultSet rs=stmt.executeQuery(sql);
while(rs.next()) {%>
您的第一个字段内容为:<%=rs.getString(1)%>
您的第二个字段内容为:<%=rs.getString(2)%>
<%}%>
<%out.print("数据库操作成功,恭喜你");%>
<%rs.close();
stmt.close();
conn.close();
%>
</body>
</html>

 

posted on 2006-01-09 13:33 joeyeezhang 阅读(501) 评论(0)  编辑  收藏 所属分类: Database

只有注册用户登录后才能发表评论。


网站导航: