⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 trysimplemapping.java

📁 此程序都是企业级 的数据库开发程序 全面揭示了JAVA对数据库的操作
💻 JAVA
字号:
import java.sql.*;

public class TrySimpleMapping {
  public static void main(String[] args) {
    TrySimpleMapping SQLtoJavaExample;
    try {
      SQLtoJavaExample = new TrySimpleMapping();
      SQLtoJavaExample.listRecordings();
    } catch (SQLException sqle) {
      System.err.println(sqle);
    } catch (ClassNotFoundException cnfe) {
      System.err.println(cnfe);
    } 
  } 

  public TrySimpleMapping() throws SQLException, ClassNotFoundException {
    Class.forName(driverName);
    connection = DriverManager.getConnection(sourceURL, user, password);
  }

  public void listRecordings() throws SQLException {
    Recording recording;

    String query = 
      "SELECT recordingid, recordingtitle, publisherid, catalognumber, recordingformatid, releasedate, languageid, listprice from recordings";

    Statement statement = connection.createStatement();
    ResultSet recordings = statement.executeQuery(query);

    while (recordings.next()) {
      int id = recordings.getInt(1);
      String title = recordings.getString(2);
      int publisherId = recordings.getInt(3);
      String catalogNumber = recordings.getString(4);
      int recordingFormat = recordings.getInt(5);
      Date releaseDate = recordings.getDate(6);
      int languageId = recordings.getInt(7);
      double listPrice = recordings.getDouble(8);

      recording = new Recording(id, title, publisherId, catalogNumber, 
                                recordingFormat, releaseDate, languageId, 
                                listPrice);

      System.out.println("\n" + recording);
    } 
    recordings.close();
    connection.close();
  } 

  Connection connection;
  String driverName = "COM.cloudscape.core.JDBCDriver";
  String sourceURL = "jdbc:cloudscape:Wrox4370.db";
  String user = "guest";
  String password = "guest";
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -