隨筆 - 26, 文章 - 0, 評論 - 2, 引用 - 0
          數據加載中……

          數據庫配置 jdbc.xml

          <?xml version="1.0" encoding="UTF-8"?>
          <!--
          ?? The JDBC module is used to configure the database access for MMBase. This module is essential. Do not remove it or make it inactive.
          -->

          ? - When org.mmbase.module.database.JDBC is used, the MMBase Connection pooling is used.
          ??? required properties for this class are:
          ??? - url
          ??? - user
          ??? - password
          ??? - supportclass
          ??? - database
          ??? - connections
          ??? - probetime
          ??? - host
          ??? - driver
          ??? - port
          ??? - host

          ? -->
          ? <class>org.mmbase.module.database.JDBC</class>

          ? ? <property name="url">jdbc:mysql://$HOST:$PORT/$DBM</property>

          ??? <!-- MySQL
          ??? <property name="url">jdbc:mysql://$HOST:$PORT/$DBM</property>
          ??? -->
          ??? <!-- MySQL when it is configured to use utf-8. The data in the database will also be readable by other programs tested on mysql 4.1
          ??? <property name="url">jdbc:mysql://$HOST:$PORT/$DBM?useUnicode=true&amp;characterEncoding=UTF-8</property>
          ??? -->
          ??? <!-- Oracle
          ???????? MM: I don' think this is regularly tested.
          ??? <property name="url">jdbc:oracle:oci8:@$DBM</property>
          ??? -->
          ??? <!-- Informix
          ??? <property name="url">jdbc:informix-sqli://$HOST:$PORT/$DBM:informixserver=[DBSERVERNAME]</property>
          ??? -->
          ??? <!-- Postgresql using the official postgresql driver
          ??? <property name="url">jdbc:postgresql://$HOST:$PORT/$DBM</property>
          ??? -->
          ??? <!-- Postgresql using the
          http://jxdbcon.sourceforge.net/ dirver
          ???????? MM: I don' think this is regularly tested
          ??? <property name="url">jdbc:pgsql:net//$HOST:$PORT/$DBM</property>
          ??? -->
          ??? <!-- MS Sql Server
          ???????? MM: I don' think this is regularly tested.
          ??? <property name="url">jdbc:microsoft:sqlserver://$HOST:$PORT;DatabaseName=$DBM</property>
          ??? -->
          ?
          ???
          ???

          ??? <!--
          ??? name="user", what is the user we will use to login to the database
          ??? -->
          ???
          <property name="user">root</property>

          ??? <!--
          ??? name="password", what is the password we will use to login to the database
          ??? -->
          ??? <property name="password">shieldprotect</property>

          ?? ??? <!--
          ??? name="database",
          ??? Most database engines allow you to store multiple databases in one engine.
          ??? We need to select the database we want to use within this engine.
          ??? Make sure you are using a 'empty' database when you start using mmbase to
          ??? ensure you don't create problems for other users.
          ??? -->
          ??? <property name="database">mmbase</property>

          ??? <!--
          ??? name="connections"
          ??? MMBase does its own database connection pooling? (keeping connections to the database open
          ??? over several database queries, to speed up queries by not logging in and closing
          ??? the connection on every query). 'connections' allows you to set
          ??? the number of connections MMBase keeps open to the database.
          ??? -->
          ??? <
          property name="connections">20</property>

          ??? <!--
          ??? name="host", what host will we connect to (that is running the database)
          ??? when you run mmbase on the same machine as this mmbase node it can
          ??? be set to 'localhost'
          ??? -->
          ??? <property name="host">localhost</property>

          ??? <!--
          ??? name="driver", defines the classname for the used jdbc driver this can be
          ??? obtained from the documentation from the jdbc driver you use.
          ??? -->

          ??? <!--
          ??? MySQL:????????? com.mysql.jdbc.Driver?????????????????? (
          http://www.mysql.com/downloads/api-jdbc.html )
          ??? PostgreSQL:???? org.postgresql.Driver?????????????????? (
          http://jdbc.postgresql.org/download.html )
          ??????????????????? org.sourceforge.jxdbcon.JXDBConDriver?? (
          http://jxdbcon.sourceforge.net/ )
          ??? Hypersonic:???? org.hsql.jdbcDriver???????????????????? (
          http://hsqldb.sourceforge.net/ )
          ??? HsqlDB:???????? org.hsqldb.jdbcDriver?????????????????? (
          http://hsqldb.sourceforge.net/ )
          ??? Oracle:???????? oracle.jdbc.driver.OracleDriver
          ??? Informix:?????? com.informix.jdbc.IfxDriver
          ??? M$ SQL Server?? com.microsoft.jdbc.sqlserver.SQLServerDriver??? (
          http://search.microsoft.com/search/results.aspx?st=b&na=88&View=en-us&qu=jdbc+sql+server+download )
          ??? -->
          ??
          ?<property name="driver">com.mysql.jdbc.Driver </property>
          ??? <!--
          ??? name="port" what port is this database engine running on ? you can find the port in
          ??? your database manual or ask the database admin. default ports for
          ??? supported databases are :

          ??? MySQL:????????? 3306
          ??? PostgreSQL????? 5432
          ??? Informix??????? 1527
          ??? M$ SQL Server?? 1433
          ??? Oracle????????? 1521
          ??? HSQL??????????? 0
          ??? -->
          ??? <property name="port">13306</property>

          </module>

          Class.forName("com.mysql.jdbc.Driver");
          Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:13306/db","root","password");
          Statement stat = conn.createStatement();
          ResultSet rs = stat.executeQuery("select * from tb_article where category='"+category+"' ");
          <ul>
          <%while(rs.next()){%>
          <li>
          <a href="showArticle.jsp?id=<%=rs.getString("id")%>"> <%=rs.getString("title")%> </a> <%=rs.getString("createdDate")%>
          </li>

          posted on 2008-07-30 09:58 Anderson 閱讀(591) 評論(0)  編輯  收藏 所屬分類: java

          主站蜘蛛池模板: 江口县| 华池县| 新化县| 新田县| 阿拉善盟| 张北县| 通化县| 岳阳县| 石门县| 柘城县| 临澧县| 荥经县| 阜平县| 晋城| 崇礼县| 五峰| 兴文县| 剑川县| 永兴县| 余干县| 潢川县| 鞍山市| 西宁市| 阳东县| 盐城市| 青铜峡市| 安阳县| 岢岚县| 梓潼县| 昌平区| 茂名市| 邯郸市| 洛宁县| 青河县| 阿城市| 宜兰市| 浮山县| 曲阜市| 中山市| 乐都县| 周至县|