这个东西很简单,你需要有
jdbc,awt, swing(主要是table和tableModel)的基础
你自己写吧,写出来也有成就感,要我们帮你写,你永远也进步不了这个东西你
1、使用jdbc方式连接数据库
2、执行查询数据库的sql语句,最后加上order by no
3、定义自己的table和tableModel
4、将查询出来的数据存储到tableModel上,用table显示出来
基本就这么多了,多练习
下面是我刚从oracle网站上找出来oci连接的一个例子http://download-west.oracle.com/docs/cd/B10501_01/java.920/a96654/getsta.htm#1001200/*
* This sample can be used to check the JDBC installation.
* Just run it and provide the connect information. It will select
* "Hello World" from the database.
*/// You need to import the java.sql package to use JDBC
import java.sql.*;// We import java.io to be able to read from the command line
import java.io.*;class JdbcCheckup
{
public static void main(String args[])
throws SQLException, IOException
{
// Load the Oracle JDBC driver
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver()); // Prompt the user for connect information
System.out.println("Please enter information to test connection to
the database");
String user;
String password;
String database; user = readEntry("user: ");
int slash_index = user.indexOf('/');
if (slash_index != -1)
{
password = user.substring(slash_index + 1);
user = user.substring(0, slash_index);
}
else
password = readEntry("password: ");
database = readEntry("database(a TNSNAME entry): "); System.out.print("Connecting to the database...");
System.out.flush(); System.out.println("Connecting...");
Connection conn = DriverManager.getConnection
("jdbc:oracle:oci:@" + database, user, password);
System.out.println("connected."); // Create a statement
Statement stmt = conn.createStatement(); // Do the SQL "Hello World" thing
ResultSet rset = stmt.executeQuery("select 'Hello World'
from dual"); while (rset.next())
System.out.println(rset.getString(1));
// close the result set, the statement and connect
rset.close();
stmt.close();
conn.close();
System.out.println("Your JDBC installation is correct.");
} // Utility function to read a line from standard input
static String readEntry(String prompt)
{
try
{
StringBuffer buffer = new StringBuffer();
System.out.print(prompt);
System.out.flush();
int c = System.in.read();
while (c != '\n' && c != -1)
{
buffer.append((char)c);
c = System.in.read();
}
return buffer.toString().trim();
}
catch(IOException e)
{
return "";
}
}
}
jdbc,awt, swing(主要是table和tableModel)的基础
你自己写吧,写出来也有成就感,要我们帮你写,你永远也进步不了这个东西你
1、使用jdbc方式连接数据库
2、执行查询数据库的sql语句,最后加上order by no
3、定义自己的table和tableModel
4、将查询出来的数据存储到tableModel上,用table显示出来
基本就这么多了,多练习
下面是我刚从oracle网站上找出来oci连接的一个例子http://download-west.oracle.com/docs/cd/B10501_01/java.920/a96654/getsta.htm#1001200/*
* This sample can be used to check the JDBC installation.
* Just run it and provide the connect information. It will select
* "Hello World" from the database.
*/// You need to import the java.sql package to use JDBC
import java.sql.*;// We import java.io to be able to read from the command line
import java.io.*;class JdbcCheckup
{
public static void main(String args[])
throws SQLException, IOException
{
// Load the Oracle JDBC driver
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver()); // Prompt the user for connect information
System.out.println("Please enter information to test connection to
the database");
String user;
String password;
String database; user = readEntry("user: ");
int slash_index = user.indexOf('/');
if (slash_index != -1)
{
password = user.substring(slash_index + 1);
user = user.substring(0, slash_index);
}
else
password = readEntry("password: ");
database = readEntry("database(a TNSNAME entry): "); System.out.print("Connecting to the database...");
System.out.flush(); System.out.println("Connecting...");
Connection conn = DriverManager.getConnection
("jdbc:oracle:oci:@" + database, user, password);
System.out.println("connected."); // Create a statement
Statement stmt = conn.createStatement(); // Do the SQL "Hello World" thing
ResultSet rset = stmt.executeQuery("select 'Hello World'
from dual"); while (rset.next())
System.out.println(rset.getString(1));
// close the result set, the statement and connect
rset.close();
stmt.close();
conn.close();
System.out.println("Your JDBC installation is correct.");
} // Utility function to read a line from standard input
static String readEntry(String prompt)
{
try
{
StringBuffer buffer = new StringBuffer();
System.out.print(prompt);
System.out.flush();
int c = System.in.read();
while (c != '\n' && c != -1)
{
buffer.append((char)c);
c = System.in.read();
}
return buffer.toString().trim();
}
catch(IOException e)
{
return "";
}
}
}
还有,1.直接访问数据库服务器的数据库就可以了,本地的机子不用装什么东西(比如oracle或客户端)了吧?
2.要求显示数据的UI使用AWT;用什么组件呢
不太知道swing(table和tableModel)期待回答,谢谢
要求显示数据的UI使用AWT;数据显示每页20条,上上下翻页功能;
这部怎么做呀
有没有例子呀