<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearch/1.1/' xmlns:georss='http://www.georss.org/georss' xmlns:thr='http://purl.org/syndication/thread/1.0' xmlns:gd='http://schemas.google.com/g/2005' gd:etag='W/&quot;DU8MRHozeip7ImA9WhdTEU4.&quot;'><id>tag:blogger.com,1999:blog-7639960492649019603</id><updated>2011-07-08T23:11:25.482+08:00</updated><category term='JAVA'/><title>湛藍工坊</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://user90083.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7639960492649019603/posts/default?redirect=false&amp;v=2'/><link rel='alternate' type='text/html' href='http://user90083.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>放空</name><uri>http://www.blogger.com/profile/09551703606585112333</uri><email>noreply@blogger.com</email></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>1</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry gd:etag='W/&quot;CEUBRXY6eSp7ImA9Wx5SF00.&quot;'><id>tag:blogger.com,1999:blog-7639960492649019603.post-4003958682430542026</id><published>2010-08-13T20:20:00.001+08:00</published><updated>2010-08-13T20:24:14.811+08:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2010-08-13T20:24:14.811+08:00</app:edited><category scheme='http://www.blogger.com/atom/ns#' term='JAVA'/><title>JAVA&amp;ACCESS 讀取資料庫內資料並顯示執行結果</title><content type='html'>使用JAVA實做資料庫連線字串 並將ACCESS資料庫內資料讀取出來&lt;br /&gt;
&lt;br /&gt;
顯示在畫面上&lt;br /&gt;
&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;
&lt;pre class="brush:java"&gt;import java.io.*;
import java.sql.*;
import jxl.*;
public class AccseeODBCTest {
 public static void main(String[] argv){
  String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
  ResultSet re;
  try {
   Class.forName(driver); 
   Connection cnDB = DriverManager.getConnection("jdbc:odbc:myAccess");
   Statement stmt = cnDB.createStatement();
   re = stmt.executeQuery("SELECT COUNT(*) AS allTable FROM StudentTable");
   if(re.next()){
    if(re.getInt("allTable")==0)System.out.println("目前尚無資料");
   }
   re = stmt.executeQuery("SELECT * FROM StudentTable");
   while(re.next()){
    System.out.println(
     "客戶編號: " +re.getObject("客戶編號")+ "\n" +
     "客戶姓名: " +re.getObject("客戶姓名")+ "\n" +
     "---------------------------------------------\n"
    );
   }
   stmt.close();
   cnDB.close();
  } 
  catch(ClassNotFoundException e) { 
   System.out.println("找不到驅動程式類別"); 
  } 
  catch(SQLException e) { 
   System.out.println("找不到資料庫路徑"); 
   e.printStackTrace();
  }
 }// end of main
}// end of class
&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7639960492649019603-4003958682430542026?l=user90083.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://user90083.blogspot.com/feeds/4003958682430542026/comments/default' title='張貼意見'/><link rel='replies' type='text/html' href='http://user90083.blogspot.com/2010/08/java-jdbcodbcdriver.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7639960492649019603/posts/default/4003958682430542026?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7639960492649019603/posts/default/4003958682430542026?v=2'/><link rel='alternate' type='text/html' href='http://user90083.blogspot.com/2010/08/java-jdbcodbcdriver.html' title='JAVA&amp;ACCESS 讀取資料庫內資料並顯示執行結果'/><author><name>放空</name><uri>http://www.blogger.com/profile/09551703606585112333</uri><email>noreply@blogger.com</email></author><thr:total>0</thr:total></entry></feed>