access转derby


package a;

import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.util.ArrayList;
import java.util.HashMap;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPopupMenu;
import javax.swing.JScrollBar;
import javax.swing.JScrollPane;
import javax.swing.JTextPane;
import javax.swing.UIManager;
import javax.swing.plaf.FontUIResource;
import javax.swing.text.SimpleAttributeSet;
import javax.swing.text.Style;
import javax.swing.text.StyleConstants;
import javax.swing.text.StyledDocument;

public class Main extends JFrame {

	public static void main(String[] args) throws Exception {

		Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
		Connection conn = DriverManager.getConnection("jdbc:derby:HolyBible");
		PreparedStatement ps = conn.prepareStatement("insert into t_HolyBible (FullName, ShortName, PY, ChapterSN, VerseSN, strjw, NCB, LCC, TCB, NIV) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
		ArrayList<HashMap<String, Object>> alhmso = Main.select("", "", "");
		for (HashMap<String, Object> hmso : alhmso) {
			ps.setString(1, hmso.get("FullName").toString());
			ps.setString(2, hmso.get("ShortName").toString());
			ps.setString(3, hmso.get("PY").toString());
			ps.setString(4, hmso.get("ChapterSN").toString());
			ps.setString(5, hmso.get("VerseSN").toString());
			ps.setString(6, hmso.get("strjw").toString());
			ps.setString(7, hmso.get("NCB").toString());
			ps.setString(8, hmso.get("LCC").toString());
			ps.setString(9, hmso.get("TCB").toString());
			ps.setString(10, hmso.get("NIV").toString());
			ps.executeUpdate();

		}
		if (ps != null) {
			ps.close();
			ps = null;
		}
		if (conn != null) {
			conn.close();
			conn = null;
		}
		// ArrayList<HashMap<String, Object>> alhmso = new ArrayList<>();
		// for (HashMap<String, Object> hmso : alhmso) {
		// try {
		// Class.forName("org.sqlite3.jdbc");
		// try (Connection conn =
		// DriverManager.getConnection("jdbc:ucanaccess://bible7.dat", "admin",
		// "gqrjabcde")) {
		// try (PreparedStatement ps = conn
		// .prepareStatement("insert into t_shengjing values (?, ?, ?, ?, ?, ?,
		// ?, ?, ?, ?, ?, ? )")) {

		//
		// ps.executeUpdate();
		// }
		// }
		// } catch (
		//
		// Exception e) {
		// e.printStackTrace();
		// }
		// }

	}

	private static final String[] s = { "创世记", "出埃及记", "利未记", "民数记", "申命记", "约书亚记", "士师记", "路得记", "撒母耳记上", "撒母耳记下", "列王纪上", "列王纪下", "历代志上", "历代志下", "以斯拉记", "尼希米记", "以斯帖记", "约伯记", "诗篇", "箴言", "传道书", "雅歌", "以赛亚书", "耶利米书", "耶利米哀歌", "以西结书", "但以理书", "何西阿书", "约珥书", "阿摩司书", "俄巴底亚书", "约拿书", "弥迦书", "那鸿书", "哈巴谷书", "西番雅书", "哈该书", "撒迦利亚书", "玛拉基书", "马太福音", "马可福音", "路加福音", "约翰福音", "使徒行传", "罗马书", "哥林多前书", "哥林多后书", "加拉太书", "以弗所书", "腓立比书", "歌罗西书", "帖撒罗尼迦前书", "帖撒罗尼迦后书", "提摩太前书", "提摩太后书", "提多书", "腓利门书", "希伯来书", "雅各书", "彼得前书", "彼得后书", "约翰壹书", "约翰贰书", "约翰叁书", "犹大书", "启示录" };
	public static final String[] s0 = { "律法书", "王国前历史书", "王国时历史书", "被掳后历史书", "诗歌·智慧书", "大先知书", "王国时小先知书", "被掳后小先知书", "四福音", "教会历史", "保罗书信", "其他使徒书信", "对约翰的启示", "退出" };
	private static final String[] s1 = { "创世记", "出埃及记", "利未记", "民数记", "申命记" };
	private static final String[] s2 = { "约书亚记", "士师记", "路得记" };
	private static final String[] s3 = { "撒母耳记上", "撒母耳记下", "列王纪上", "列王纪下", "历代志上", "历代志下" };
	private static final String[] s4 = { "以斯拉记", "尼希米记", "以斯帖记" };
	private static final String[] s5 = { "约伯记", "诗篇", "箴言", "传道书", "雅歌" };
	private static final String[] s6 = { "以赛亚书", "耶利米书", "耶利米哀歌", "以西结书", "但以理书" };
	private static final String[] s7 = { "何西阿书", "约珥书", "阿摩司书", "俄巴底亚书", "约拿书", "弥迦书", "那鸿书", "哈巴谷书", "西番雅书" };
	private static final String[] s8 = { "哈该书", "撒迦利亚书", "玛拉基书" };
	private static final String[] s9 = { "马太福音", "马可福音", "路加福音", "约翰福音" };
	private static final String[] s10 = { "使徒行传" };
	private static final String[] s11 = { "罗马书", "哥林多前书", "哥林多后书", "加拉太书", "以弗所书", "腓立比书", "歌罗西书", "帖撒罗尼迦前书", "帖撒罗尼迦后书", "提摩太前书", "提摩太后书", "提多书", "腓利门书" };
	private static final String[] s12 = { "希伯来书", "雅各书", "彼得前书", "彼得后书", "约翰壹书", "约翰贰书", "约翰叁书", "犹大书" };
	private static final String[] s13 = { "启示录" };
	private static final String[] sExit = { "退出" };
	public static final String[][] sShengJing = { s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, sExit };
	public static Color[] c = { new Color(255, 64, 64), new Color(255, 128, 64), new Color(255, 255, 0), new Color(128, 255, 128), new Color(128, 255, 255), new Color(0, 152, 255), new Color(255, 0, 255), new Color(255, 128, 255) };
	public static Color[] c1 = { Color.RED, Color.ORANGE, Color.YELLOW, Color.GREEN, Color.CYAN, Color.BLUE, Color.MAGENTA, Color.PINK };

	public static ArrayList<HashMap<String, Object>> select(String juan, String zhang, String jie) {
		ArrayList<HashMap<String, Object>> alhmso = new ArrayList<HashMap<String, Object>>();
		try {
			Class.forName("net.ucanaccess.jdbc.UcanaccessDriver");
			try (Connection conn = DriverManager.getConnection("jdbc:ucanaccess://bible7.dat", "admin", "gqrjabcde")) {
				try (PreparedStatement ps = conn.prepareStatement("select * from bible, bibleid where bible.VolumeSN = bibleid.SN order by bible.id asc")) {
					// ps.setString(1, juan);
					// ps.setString(2, zhang);
					// ps.setString(3, jie);
					try (ResultSet rs = ps.executeQuery()) {
						ResultSetMetaData rsmd = rs.getMetaData();
						int getColumnCount = rsmd.getColumnCount();
						while (rs.next()) {
							HashMap<String, Object> hmso = new HashMap<String, Object>();
							for (int i = 1; i <= getColumnCount; i++) {
								String getColumnName = rsmd.getColumnName(i);
								Object sCellValue = rs.getObject(getColumnName);
								if (sCellValue == null) {
									sCellValue = "";
								}
								hmso.put(getColumnName, sCellValue);
							}
							alhmso.add(hmso);
						}
					}
				}
			}
		} catch (

		Exception e) {
			e.printStackTrace();
		}
		return alhmso;
	}
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值