随笔 - 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 阅读(576) 评论(0)  编辑  收藏 所属分类: java


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


网站导航: