際際滷

際際滷Share a Scribd company logo
Java thegioiebook 3216
Ch動董ng 1

Gi畛i thi畛u ng担n ng畛
l畉p tr狸nh Java
Gi畛i thi畛u
 S畛 ph叩t tri畛n c畛a Java
 H動畛ng t畛i ng動畛i d湛ng
 Gi畛ng v畛i C / C++
C叩c 畉c tr動ng c畛a Java
董n gi畉n
H動畛ng 畛i t動畛ng
畛c l畉p ph畉n c畛ng
M畉nh
B畉o m畉t
Ph但n t叩n
a lu畛ng
畛ng
C叩c ch動董ng tr狸nh d畛ch
truy畛n th畛ng
Database Metadata
 畛i t動畛ng ny cho bi畉t th担ng tin v畛 csdl.
Ch動董ng tr狸nh m畉u
import java.sql.*;
class JDBCDemo1 {
public static void main(String[] args) {
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:Accserver");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(args[0]);
ResultSetMetaData rsmd = rs.getMetaData();
int numberOfColumns = rsmd.getColumnCount();
for(int j=1; j<=numberOfColumns;j++) {
System.out.println(rsmd.getColumnLabel(j));
}
while(rs.next()) {
for(int i=1; i<=numberOfColumns;i++){
System.out.println(rs.getObject(i));
}}
rs.close();
stmt.close();
} catch(Exception e){ System.out.println("Error " + e);

More Related Content

Java thegioiebook 3216

  • 2. Ch動董ng 1 Gi畛i thi畛u ng担n ng畛 l畉p tr狸nh Java
  • 3. Gi畛i thi畛u S畛 ph叩t tri畛n c畛a Java H動畛ng t畛i ng動畛i d湛ng Gi畛ng v畛i C / C++
  • 4. C叩c 畉c tr動ng c畛a Java 董n gi畉n H動畛ng 畛i t動畛ng 畛c l畉p ph畉n c畛ng M畉nh B畉o m畉t Ph但n t叩n a lu畛ng 畛ng
  • 5. C叩c ch動董ng tr狸nh d畛ch truy畛n th畛ng
  • 6. Database Metadata 畛i t動畛ng ny cho bi畉t th担ng tin v畛 csdl.
  • 7. Ch動董ng tr狸nh m畉u import java.sql.*; class JDBCDemo1 { public static void main(String[] args) { try{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con=DriverManager.getConnection("jdbc:odbc:Accserver"); Statement stmt = con.createStatement(); ResultSet rs = stmt.executeQuery(args[0]); ResultSetMetaData rsmd = rs.getMetaData(); int numberOfColumns = rsmd.getColumnCount(); for(int j=1; j<=numberOfColumns;j++) { System.out.println(rsmd.getColumnLabel(j)); } while(rs.next()) { for(int i=1; i<=numberOfColumns;i++){ System.out.println(rs.getObject(i)); }} rs.close(); stmt.close(); } catch(Exception e){ System.out.println("Error " + e);