<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>聰明的生活2 &#187; database</title>
	<atom:link href="http://blog.yslifes.com/archives/tag/database/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.yslifes.com</link>
	<description>自己寫java程式的一些筆記</description>
	<lastBuildDate>Wed, 08 Feb 2012 02:26:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<atom:link rel='hub' href='http://blog.yslifes.com/?pushpress=hub'/>
		<item>
		<title>[JAVA]聯絡我們表單程式後台</title>
		<link>http://blog.yslifes.com/archives/980</link>
		<comments>http://blog.yslifes.com/archives/980#comments</comments>
		<pubDate>Thu, 02 Feb 2012 15:32:00 +0000</pubDate>
		<dc:creator>yku</dc:creator>
				<category><![CDATA[ajax]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[easyui]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jsp]]></category>
		<category><![CDATA[程式]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://blog.yslifes.com/?p=980</guid>
		<description><![CDATA[前一篇介紹過聯絡我們的的前台程式，這篇會介紹如何取得前台聯絡表單所留言的內容，使用的網頁使用framework有jquery及easyui，利用datagrid來顯示所有的資料列，而重要的留言內容則顯示於iframe裡，如此可排除大部份的html tag產生的問題。 這程式目前缺少了幾個功能，並不影響使用，不過如果有需求的人倒可以自己加入使用： 前台留言後自動發mail給某位管理者 後台可回覆留言給使用者，寄送mail或電話聯絡後寫下聯絡事項 最主要是JavaMail的使用，及資料寫入資料庫的應用。 因為是後台，所以還需要一個登入畫面，再登入成功後可以顯示後台menus，利用easyui的layout排列north為資訊狀態，center為datagrid顯示聯絡資料列表，而east為留言的內容。 而網頁使用Ajax傳送get或post參數給後端，而後端程式回傳json格式如下： total：總筆數，grid顯示分頁toolbar使用的，會計算總頁數等… success：成功執行則回傳true，否則則回傳false msg：回傳的訊息，可於回傳success為false時，帶上錯誤訊息顯示給使用者知道 rows：為一個陣列資料，每一筆資料都是一個json格式 程式碼如下： index.jsp登入後台 &#60;%@ page language=&#34;java&#34; contentType=&#34;text/html; charset=UTF-8&#34; pageEncoding=&#34;UTF-8&#34;%&#62; &#60;!DOCTYPE html PUBLIC &#34;-//W3C//DTD HTML 4.01 Transitional//EN&#34; &#34;http://www.w3.org/TR/html4/loose.dtd&#34;&#62; &#60;html&#62; &#60;head&#62; &#60;meta http-equiv=&#34;Content-Type&#34; content=&#34;text/html; charset=UTF-8&#34;&#62; &#60;title&#62;登入&#60;/title&#62; &#60;style type=&#34;text/css&#34;&#62; html,body{ margin:0; padding:0; height:100%; border:none } &#60;/style&#62; &#60;script type=&#34;text/javascript&#34; src=&#34;js/jquery-1.7.1.min.js&#34;&#62;&#60;/script&#62; &#60;script type=&#34;text/javascript&#34; src=&#34;js/jquery.form.js&#34;&#62;&#60;/script&#62; &#60;script type=&#34;text/javascript&#34;&#62; $(function(){ $(document).ready(function() { [...]]]></description>
		<wfw:commentRss>http://blog.yslifes.com/archives/980/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[PHP]自動取號(編碼)程式</title>
		<link>http://blog.yslifes.com/archives/978</link>
		<comments>http://blog.yslifes.com/archives/978#comments</comments>
		<pubDate>Thu, 05 Jan 2012 15:38:15 +0000</pubDate>
		<dc:creator>yku</dc:creator>
				<category><![CDATA[database]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[程式]]></category>
		<category><![CDATA[autoencode]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://blog.yslifes.com/archives/978</guid>
		<description><![CDATA[使用php撰寫程式的人，最常使用的資料庫應該是MySQL，MySQL本身已經有提供自動取號的功能，不過在某些狀況上可能並不適用，而已也有些資料庫並沒有提供自動給號的功能的。 自動取號，主要用在key值的產生，可以得到唯一的編號，而這個編號是有一定規則的，像是（檔頭＋年份＋流水號）之類的，用來識別此筆資料，而產生這個編號有很多種方式，如： 資料庫本身提供此功能,ex:mysql的Auto Increment 利用一個Table存放目前編號，再使用stored procedure或是程資語言來取號 其它... 之前有寫過一個Oracle Store procedure的取號程式，而這次提供利用php程式來取得編號，取號的原則有幾個來確保取號不會錯誤： 取號後，不管有無使用，則此編號已不會再產生 要使用transaction功能來取號及存入取到號碼（此範例並未用到交易） 這個範列的結果 編碼用Table(autoencode) CREATE TABLE `autoencode` &#40; `code_type` VARCHAR&#40;50&#41; NOT NULL, `code_head` VARCHAR&#40;10&#41; NOT NULL, `code_count` BIGINT&#40;20&#41; NOT NULL, `code_max` INT&#40;11&#41; NOT NULL DEFAULT '10', PRIMARY KEY &#40;`code_type`&#41; &#41; ENGINE=InnoDB DEFAULT CHARSET=utf8 編碼程式內容 &#160; define&#40;'DB_HOST', &#34;localhost&#34;&#41;; //資料庫主機位置 define&#40;'DB_LOGIN', &#34;root&#34;&#41;; //資料庫的使用帳號 define&#40;'DB_PASSWORD', &#34;12345&#34;&#41;; //資料庫的使用密碼 define&#40;'DB_NAME', [...]]]></description>
		<wfw:commentRss>http://blog.yslifes.com/archives/978/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>c3p0 ConnectionPools設置與使用</title>
		<link>http://blog.yslifes.com/archives/975</link>
		<comments>http://blog.yslifes.com/archives/975#comments</comments>
		<pubDate>Mon, 12 Dec 2011 14:44:12 +0000</pubDate>
		<dc:creator>yku</dc:creator>
				<category><![CDATA[database]]></category>
		<category><![CDATA[Exception]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[opensource]]></category>
		<category><![CDATA[程式]]></category>
		<category><![CDATA[jdbc]]></category>
		<category><![CDATA[source]]></category>
		<category><![CDATA[sql server]]></category>

		<guid isPermaLink="false">http://blog.yslifes.com/archives/975</guid>
		<description><![CDATA[c3p0是一個基於JNDI-bindable DataSources(使用DriverManager-based)的很容易使用的JDBC驅動函數庫。 所以在使用c3p0時，還需要一個JDBC的Driver，才能使用，而c3p0的作用只是控制Database的Connection使用，舉個簡單的例子，當Connection被DataBase Server timeout斷線後，c3p0會自動多次去重新連線，避免程式就直接丟出SQLException。 這次剛好遇到Microsoft SQL Server 2005不知為何一直丟出以下訊息，才去找到c3p0來使用的，發生的原因似乎是SQL Server本身對JDBC的Connection TimeOut斷線、或是Connection數不夠。 I/O Error: Connection reset I/O Error: Software caused connection abort: recv failed 下面是一個範例，結果如下圖： package com.yslifes; &#160; import java.beans.PropertyVetoException; import java.sql.SQLException; &#160; import javax.sql.DataSource; &#160; import com.mchange.v2.c3p0.ComboPooledDataSource; &#160; public class DB &#123; private static ComboPooledDataSource ds = null; public static DataSource getPool&#40;&#41; throws java.sql.SQLException &#123; [...]]]></description>
		<wfw:commentRss>http://blog.yslifes.com/archives/975/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Csharp使用ADO.NET操作SQLite</title>
		<link>http://blog.yslifes.com/archives/972</link>
		<comments>http://blog.yslifes.com/archives/972#comments</comments>
		<pubDate>Sun, 30 Oct 2011 02:10:35 +0000</pubDate>
		<dc:creator>yku</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[opensource]]></category>
		<category><![CDATA[VisualStudio]]></category>
		<category><![CDATA[程式]]></category>
		<category><![CDATA[csharp]]></category>
		<category><![CDATA[datasource]]></category>
		<category><![CDATA[free]]></category>
		<category><![CDATA[source]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[sqlite]]></category>

		<guid isPermaLink="false">http://blog.yslifes.com/archives/972</guid>
		<description><![CDATA[SQLite是一個簡易的資料庫系統，開放原始碼，可以直接把SQLite綁在程式裡使用，FireFox及Android等軟體也都有內建SQLite。SQLite不需要安裝，看起來就只是一個檔案而已，也可以使用memory模式，讓它存在記憶體中而不需要建立一個檔案存放。 SQLite支援的SQL指令：http://www.sqlite.org/lang_corefunc.html C#要連接SQLite可以使用open source的System.Data.SQLite，它是一個基於ADO.Net所做與SQLite的溝通介面，目前支援到.net framework 3.5。可於sourceforge下載其dll來使用，就可以了。 下方的範例是介紹如何在Csharp下使用ADO.NET連接與操作SQLite，包含了自動產生SQLite檔案與DataGridView使用class binding datasource方法。 一、建立一個專案，並先將其儲存起來 (需要先建置專案才能使用專案裡的class當做datasource) 二、改變專案使用的Framework 在專案節點上選擇屬性 把目標Framework(G):改成.NET Framework 3.5以下 告知需要重新啟動專案 三、加入System.Data.SQLite的Dll當做參考 在專案裡的參考節點上按右鍵選加入參考(R).... 找到DLL加入 在參考的節點上可以看到System.Data.SQLite已加入成功 因為原本專案為.NET Framework 4被降為3.5，所以會多出一個無法使用的參考Microsoft CSharp，此時可順便移除掉它。 四、建立相容模式 SQLite ADO.NET是建立於版本v2.0.50727，所以在比較高的版本會有相容性問題，所以修改app.config或web.config來使其相容使用。 ps.有一說可以在.NET Framework 4.0修改設定則可以使用SQLite ADO.NET 在startup的tag上加上屬性 &#60;startup useLegacyV2RuntimeActivationPolicy=&#34;true&#34;&#62; &#60;supportedRuntime version=&#34;v2.0.50727&#34;/&#62; &#60;/startup&#62; 在範列裡我們會使用到二種建立SQLite Connection的方法，其中一種為DbProvider，所以需要使用到以下tag內容，放在configuration內就可以了，如果不使用此種DbProvider方法，也可不加。 &#60;system.data&#62; &#60;DbProviderFactories&#62; &#60;remove invariant=&#34;System.Data.SQLite&#34;/&#62; &#60;add name=&#34;SQLite Data Provider&#34; invariant=&#34;System.Data.SQLite&#34; description=&#34;.Net Framework Data Provider for SQLite&#34; [...]]]></description>
		<wfw:commentRss>http://blog.yslifes.com/archives/972/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java使用JDBC操作SQLite</title>
		<link>http://blog.yslifes.com/archives/971</link>
		<comments>http://blog.yslifes.com/archives/971#comments</comments>
		<pubDate>Sat, 08 Oct 2011 16:05:34 +0000</pubDate>
		<dc:creator>yku</dc:creator>
				<category><![CDATA[database]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[程式]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[jdbc]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[sqlite]]></category>
		<category><![CDATA[資料庫]]></category>

		<guid isPermaLink="false">http://blog.yslifes.com/archives/971</guid>
		<description><![CDATA[SQLite是一個輕量級的資料庫系統，不需要安裝就可以使用，也可以十分容易的就內嵌於系統內，FireFox就內嵌SQLite，可以在FireFox上直接使用JavaScript來呼叫操作資料庫。 SQLite是由C語言撰寫而已，可以跨Linux及Windows等平台，在Java存取及操作上則可使用JDBC來連線SQLite。 在JDBC連線SQLite上，大概分成二種方式，一種是由Pure-Java來連結資料，另一種則是直接利用Java呼叫C語言撰寫的函式庫，不過在實測上直接呼叫C的函式庫的方式應該是比較快的，不過在無法找到合適C函式庫的平台則可使用Pure-Java版。 SQLiteJDBC目前查到這個版本是比較有在更新，而且在使用上跟一般的JDBC幾乎是一樣的，上手程式十分簡單。 SQLiteJDBC可以由這裡下載，以下範例是由3.5.7版本製作，提供建立Table、移除Table、查詢、新增、刪除及修改等範例。 package com.izero.sqllite; import java.sql.*; &#160; import org.sqlite.SQLiteConfig; import org.sqlite.SQLiteDataSource; public class MyTest &#123; public Connection getConnection&#40;&#41; throws SQLException &#123; SQLiteConfig config = new SQLiteConfig&#40;&#41;; // config.setReadOnly(true); config.setSharedCache&#40;true&#41;; config.enableRecursiveTriggers&#40;true&#41;; &#160; &#160; SQLiteDataSource ds = new SQLiteDataSource&#40;config&#41;; ds.setUrl&#40;&#34;jdbc:sqlite:sample.db&#34;&#41;; return ds.getConnection&#40;&#41;; //ds.setServerName(&#34;sample.db&#34;); &#160; &#160; &#125; //create Table public void createTable&#40;Connection con &#41;throws SQLException&#123; [...]]]></description>
		<wfw:commentRss>http://blog.yslifes.com/archives/971/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>csharp筆記</title>
		<link>http://blog.yslifes.com/archives/962</link>
		<comments>http://blog.yslifes.com/archives/962#comments</comments>
		<pubDate>Mon, 12 Sep 2011 08:01:02 +0000</pubDate>
		<dc:creator>yku</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[程式]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[csharp]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[datasource]]></category>

		<guid isPermaLink="false">http://blog.yslifes.com/?p=962</guid>
		<description><![CDATA[一 在DataSource元件要使用Transaction，可以增加一個參考dll(system.transactions.dll)，此dll只支援.Net 2.0以上，然後使用TransactionScope來在指定區域內做Transaction 參考資料網址：http://msdn.microsoft.com/zh-tw/library/system.transactions.transactionscope(VS.80).aspx using System.Transactions; using &#40;TransactionScope scope = new TransactionScope&#40;&#41;&#41; &#123; SqlDataSource2.SelectParameters.Clear&#40;&#41;; &#160; SqlDataSource2.DeleteCommand = &#34;delete from table_name &#34;; &#160; &#160; SqlDataSource2.Update&#40;&#41;; scope.Complete&#40;&#41;; &#125; 二 GridView執行onCommand時，要如何取得執行列的此筆Row資料呢？ 假設有一個GridView如下：(需先把RowData的Index放置於CommandArgument參數裡，以便取用) &#160; &#60;asp:GridView ID=&#34;GridView1&#34; runat=&#34;server&#34;&#62; &#60;Columns&#62; &#60;asp:TemplateField&#62; &#60;ItemTemplate&#62; &#60;asp:Button ID=&#34;mybutton&#34; runat=&#34;server&#34; CommandArgument='&#60;%# Container.DataItemIndex %&#62;' OnCommand=&#34;Button_Click&#34; Text=&#34;Down&#34; CommandName=&#34;buttonit&#34; /&#62; &#60;/ItemTemplate&#62; &#60;/asp:TemplateField&#62; &#60;/Columns&#62; &#60;/asp:GridView&#62; 然後利用ExtractRowValues這個function把所有Rows的Columns的key及值取出，放到OrderedDictionary物件裡，這個方法是參考DataControlField的ExtractRowValues方法的。 &#160; private OrderedDictionary ExtractRowValues&#40;DataControlFieldCollection [...]]]></description>
		<wfw:commentRss>http://blog.yslifes.com/archives/962/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Visual Studio Express .NET C#(C Shape)連接MySQL資料庫</title>
		<link>http://blog.yslifes.com/archives/938</link>
		<comments>http://blog.yslifes.com/archives/938#comments</comments>
		<pubDate>Sun, 15 May 2011 23:16:00 +0000</pubDate>
		<dc:creator>yku</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[程式]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[csharp]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://blog.yslifes.com/archives/938</guid>
		<description><![CDATA[Microsoft Visual Studio Exrpess是微軟提供的免費而且比較簡單的.NET開發工具，跟一套數萬元的Visual Studio有著許多限制，像是在連接資料庫時就提供了比較少連接選擇方式，雖然可以用ODBC的方式來解決部份的問題，不過效能上還是直接使用Connector比較好。 MySQL提供了一個免費的Connector，可藉由此Connector來直接連接資料庫，只需要加入參考的DLL，再使用連線字串建立連線就可以使用了，不過並無法直接使用Express提供的加入新資料來源（資料庫）精靈來操作。 底下提供一個簡單的範例，利用SQLCommand來進行查詢，回傳結果。 １.安裝My SQL Connector 可由MySQL官方網站下載，請選擇Windows (x86, 32-bit), MSI Installer或是mysql-connector-net-6.3.6.zip其中一個，mysql-connector-net-6.3.6-src.zip是需要自行Complier的原始碼內容。 ２.加入參考 可直接於.NET分頁選擇MySQL.Data或是利用瀏覽來加入DLL，二者選一 ３.建立連線Connection //連接字串 String conString = &#34;SERVER = localhost; DATABASE = test; User ID = root; PASSWORD = 12345;&#34;; //取得MySQLConnection MySqlConnection connection = new MySqlConnection&#40;conString&#41;; 測試結果，原始碼： try &#123; //連接字串 String conString = &#34;SERVER = localhost; DATABASE = test; User [...]]]></description>
		<wfw:commentRss>http://blog.yslifes.com/archives/938/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JApplet與Web Server做溝通</title>
		<link>http://blog.yslifes.com/archives/934</link>
		<comments>http://blog.yslifes.com/archives/934#comments</comments>
		<pubDate>Tue, 26 Apr 2011 11:50:00 +0000</pubDate>
		<dc:creator>yku</dc:creator>
				<category><![CDATA[database]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[jsp]]></category>
		<category><![CDATA[程式]]></category>
		<category><![CDATA[applet]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[gson]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[Socket]]></category>
		<category><![CDATA[tomcat]]></category>

		<guid isPermaLink="false">http://blog.yslifes.com/archives/934</guid>
		<description><![CDATA[Applet除非是內部或自己使用時，可以直接使用JDBC來連接資料庫，而一般對外開放的服務如果讓Applet直接連接到資料庫，需要開port讓Clinet 的Applet來使用，在安全性上相對的十分危險。 此時可以利用一個中繼的Sokcet Server或是Web Server來當與資料庫連接的proxy代理服務器，如此Apllet只要連接Web Server，對Server提出需求，而Server會依需求與資料庫做溝通，並回傳Applet要求之資料，如此可以做成多層式的架構來解決Applet資料取得之問題。 範例設計上有一個輸入框JTextField可以輸入要傳給Server的資料內容，而下方的JTextArea是承接從Server回傳的資料內容，按鈕則可進行動作Action。 輸入傳送的字串後，按下”按我”可進行資料的傳送POST。 try &#123; &#160; com.yslifes.connect.WebModule web = new com.yslifes.connect.WebModule&#40;&#41;; //使用post把資料傳送到web server端 web.doPost&#40;&#34;http://localhost:8080/AppletGUIServer/Info.jsp&#34;, &#34;data=&#34;+getJTextField&#40;&#41;.getText&#40;&#41;+&#34;&#38;p=1&#34;, null, &#34;utf-8&#34;&#41;; //取回回傳的json資料 com.google.gson.JsonObject json = web.getJSON&#40;&#41;; getJTextArea&#40;&#41;.setText&#40;json.get&#40;&#34;msg&#34;&#41;.getAsString&#40;&#41;&#41;; &#160; &#160; &#160; &#125;catch&#40;Exception ex&#41; &#123; ex.printStackTrace&#40;&#41;; logger.info&#40;ex&#41;; &#160; &#125; 這裡使用到的WebModule可以參考HttpURLConnection來實作get及post動作。 在Console視窗可以看到傳送出去的資料內容： 而在WebServer方面，則可利用request來取得需要資料做處理，再回傳out.print給Applet。 &#60;%@ page language=&#34;java&#34; contentType=&#34;text/html; charset=UTF-8&#34; pageEncoding=&#34;UTF-8&#34; %&#62;&#60;% request.setCharacterEncoding&#40;&#34;utf-8&#34;&#41;; &#160; //取得傳來的參數 System.out.println&#40;&#34;data=&#34;+request.getParameter&#40;&#34;data&#34;&#41;&#41;; System.out.println&#40;&#34;p=&#34;+request.getParameter&#40;&#34;p&#34;&#41;&#41;; &#160; //回傳json [...]]]></description>
		<wfw:commentRss>http://blog.yslifes.com/archives/934/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jsp簡單留言板</title>
		<link>http://blog.yslifes.com/archives/925</link>
		<comments>http://blog.yslifes.com/archives/925#comments</comments>
		<pubDate>Sat, 16 Apr 2011 13:34:05 +0000</pubDate>
		<dc:creator>yku</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[jsp]]></category>
		<category><![CDATA[opensource]]></category>
		<category><![CDATA[程式]]></category>
		<category><![CDATA[board]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[jdbc]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[source]]></category>
		<category><![CDATA[tomcat]]></category>

		<guid isPermaLink="false">http://blog.yslifes.com/archives/925</guid>
		<description><![CDATA[這個範例有新增留言、查詢留言及留言分頁顯示等功能，後台的管理還沒有建置完成，留言者需要填入標題、顯示名稱、電話、信箱及留言內容，其中電話與電子信箱不顯示在留言列表中，電話及信箱可以為之後後台回覆寄信連絡使用。 當然這還有需多可以增加的功能，像是留言通知、隱私留言、留言刪除等，之後會再慢慢增加。 資料庫使用MySQL資料庫，使用JDBC來連接資料庫(DataSource方式)，記錄檔則是使用log4j。 在新增留言部份，submit之前會先檢查是否有未填欄位，如果檢查通過則會自動建立IFrame來給這個form的target使用，新增完成後會自動回到留言列表的頁面。 查詢留言會對資料的標題及留言內容進行比對，有相同資料就會顯示查詢的結果，如果想進階做一個Search-Engine則可以參考建立自己的搜尋引擎。 最後也就是最重要的資料顯示功能，這裡包含了一個分頁模組，傳入的參數會有s，查詢條件，及p，目前頁數。 範例檢視 資料表 CREATE TABLE `threads` &#40; `post_id` INT&#40;11&#41; NOT NULL AUTO_INCREMENT, `post_name` VARCHAR&#40;150&#41; NOT NULL, `post_title` VARCHAR&#40;300&#41; DEFAULT NULL, `post_mail` VARCHAR&#40;100&#41; DEFAULT NULL, `post_tel` VARCHAR&#40;100&#41; DEFAULT NULL, `post_desc` text, `post_reply` INT&#40;11&#41; DEFAULT NULL, `post_show` VARCHAR&#40;1&#41; DEFAULT '1', `post_state` VARCHAR&#40;1&#41; DEFAULT '1', `create_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, `create_id` INT&#40;11&#41; [...]]]></description>
		<wfw:commentRss>http://blog.yslifes.com/archives/925/feed</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Java讀取檔案匯入MySQL資料庫／取得MySQL資料存入檔案</title>
		<link>http://blog.yslifes.com/archives/920</link>
		<comments>http://blog.yslifes.com/archives/920#comments</comments>
		<pubDate>Tue, 12 Apr 2011 14:06:03 +0000</pubDate>
		<dc:creator>yku</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[opensource]]></category>
		<category><![CDATA[程式]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[jdbc]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://blog.yslifes.com/archives/920</guid>
		<description><![CDATA[範例是讀取一個csv檔案，內容每一行為一筆資料，每筆資料不同欄位以＂，＂做切割，使用split()方法來分離成String陣列／另一個範例則是相反的，從資料庫取select出資料，寫入檔案。 連MySQL接資料庫使用JDBC-Driver，方法可以參考Eclipse設定JDBC連接MySQL資料庫，這裡另外再提供一個使用DataSource的設定方法，使用起來也比較簡單。 JDBC連接資料庫，取得Connection的方法： 在需要連線時都會要求載入Driver Class，然後要求連線。 public static Connection getConnection &#40;&#41; throws SQLException &#123; try &#123; Class.forName&#40;&#34;com.mysql.jdbc.Driver&#34;&#41;.newInstance&#40;&#41;; &#125; catch&#40;Exception e&#41; &#123; &#160; &#125; Connection con=java.sql.DriverManager.getConnection&#40; &#34;jdbc:mysql://localhost/test?useUnicode=true&#38;characterEncoding=Big5&#34;,&#34;root&#34;,&#34;12345&#34;&#41;; return con; &#125; 利用建立DataSource來取得Connection： 當使用完畢Connection後，會交還DataSource，下次取用時直接取得連線資訊。 public static DataSource getPool&#40;&#41; &#123; //com.mysql.jdbc.jdbc2.optional. ds = null; com.mysql.jdbc.jdbc2.optional.MysqlDataSource ds = null; //try &#123; //ds = new oracle.jdbc.pool.OracleConnectionPoolDataSource (); ds = new com.mysql.jdbc.jdbc2.optional.MysqlDataSource&#40;&#41;; &#160; [...]]]></description>
		<wfw:commentRss>http://blog.yslifes.com/archives/920/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

