JWorld@TW the best professional Java site in Taiwan
      註冊 | 登入 | 全文檢索 | 排行榜  

» JWorld@TW » JDBC/SQL討論區  

按列印兼容模式列印這個話題 列印話題    把這個話題寄給朋友 寄給朋友    訂閱主題
reply to postflat modego to previous topicgo to next topic
本主題所含的標籤
無標籤
作者 快速測試 JSP + Mysql [by iampoya] [精華]
browser

戀香

版主

發文: 3570
積分: 1
於 2003-06-19 18:36 user profilesend a private message to usersend email to browserreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
http://www.mysql.com/downloads/api-jdbc-stable.html
Download Connector/J 3.0
檔名應該是叫mysql-connector-java-3.0.8-stable-bin.jar
測試程式

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import java.sql.*;
class TestJDBCMySQL
{
  public static void main(String[] args) throws Exception
  {  
    Class.forName("com.mysql.jdbc.Driver").newInstance(); 
    Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/mysql?user=root");
    String sql = "select * from user ";
    Statement stmt = con.createStatement();
    stmt.execute(sql);
    ResultSet rs = stmt.getResultSet();
    for(int i = 1;i <= rs.getMetaData().getColumnCount();i++) {
      System.out.print(rs.getMetaData().getColumnName(i) + "\t") ;
    }
    System.out.println( System.getProperty("line.separator")+"********************");
    while (rs.next()) {
      for(int i = 1;i <= rs.getMetaData().getColumnCount();i++) {
        System.out.print(rs.getString(i) + "\t");
      }
      System.out.println();
    }
  }
}

Good Luck !!


morchory edited on 2005-08-21 02:49
reply to postreply to post
話題樹型展開
人氣 標題 作者 字數 發文時間
29828 [精華] 快速測試 JSP + Mysql [by iampoya] browser 1009 2003-06-19 18:36
27426 Re:快速測試 JSP + Mysql [by iampoya] iampoya 35 2003-06-19 18:42
27253 Re:快速測試 JSP + Mysql [by iampoya] browser 158 2003-06-19 18:49
20050 Re:快速測試 JSP + Mysql [by iampoya] emt2a7 130 2005-05-26 11:17
21026 Re:快速測試 JSP + Mysql [by iampoya] YAMAHA50164 280 2005-06-01 15:13
19800 Re:快速測試 JSP + Mysql [by iampoya] StephenHuang 32 2006-05-02 13:47
27226 Re:快速測試 JSP + Mysql [by iampoya] JiaYun 24 2003-06-19 18:44
27969 Re:快速測試 JSP + Mysql [by iampoya] zhshfeng_xx 83 2004-01-15 14:49
26158 Re:快速測試 JSP + Mysql [by iampoya] TAHO 159 2004-01-15 15:17
26408 Re:快速測試 JSP + Mysql [by iampoya] BenClick 316 2004-02-07 00:01
23442 Re:快速測試 JSP + Mysql [by iampoya] fatdog 71 2004-08-31 10:26
23382 Re:快速測試 JSP + Mysql [by iampoya] jonz 22 2004-09-09 13:11
21998 Re:快速測試 JSP + Mysql [by iampoya] itsayr 196 2004-11-21 19:06
21920 Re:快速測試 JSP + Mysql [by iampoya] hkdennis2k 1749 2004-12-07 11:27
22766 Re:快速測試 JSP + Mysql [by iampoya] worookie 251 2004-12-07 13:41
20034 Re:快速測試 JSP + Mysql [by iampoya] emt2a7 198 2005-05-26 10:22
» JWorld@TW »  JDBC/SQL討論區

reply to postflat modego to previous topicgo to next topic
  已讀文章
  新的文章
  被刪除的文章
Jump to the top of page

JWorld@TW 本站商標資訊

Powered by Powerful JuteForum® Version Jute 1.5.8