package com.h2sql.test;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class MainClass {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Statement stmt = null;
		Connection conn = null;
		try {
			Class.forName("org.h2.Driver");
			conn = DriverManager.getConnection(
					"jdbc:h2:tcp://10.8.1.206:5435/mem:DBTest", "Guest",
					"123456");
			// add application code here
			stmt = conn.createStatement();
//			String createSql = "create table product(product_id integer not null,title varchar2(30) not null,type_id integer not null,info varchar2(80),price number(16,2) not null,constraint product_pk primary key (product_id),constraint product_fk foreign key(type_id) references item(type_id)))";
//			stmt.executeUpdate(createSql);
			// 添加一条语句
			// String insertSql =
			// "insert into UserInfo values('刘尚','10.8.1.212','888888','true',15827288756,15827288756)";
			// stmt.executeUpdate(insertSql);
			// 删除一条记录
			// String deleteSql = "delete from USERINFO where UID = '刘尚1'";
			// stmt.executeUpdate(deleteSql);
			// 修改一条语句
			// String UpdateSql =
			// "UPDATE USERINFO  SET IP='10.8.1.10' ,  LINKID='11111' , ACTION='FALSE' ,  UPTIME=2121231 ,DOWNTIME=2121212 WHERE UID='刘尚'";
			// stmt.executeUpdate(deleteSql);
			ResultSet rs = stmt.executeQuery("SELECT * FROM UserInfo ");
			 while (rs.next()) {
			 System.out.println("Uid:" + rs.getString("Uid") + "\tIp:"
			 + rs.getString("Ip") + "\tLinkId:"
			 + rs.getString("LinkId") + "\tAction:"
			 + rs.getBoolean("Action") + "\tUpTime:"
			 + rs.getLong("UpTime") + "\tDownTime:"
			 + rs.getLong("DownTime"));
			 }
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			try {
				if (stmt != null) {
					stmt.close();
					stmt = null;
				}
				if (conn != null) {
					conn.close();
					conn = null;
				}
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}

}
最近下载更多
akbar2020  LV9 2022年8月27日
497570230  LV1 2021年12月31日
fh201314  LV1 2020年8月23日
ruanjain3198225  LV2 2020年6月16日
希望依然  LV6 2020年5月20日
lxj137258  LV3 2020年4月29日
yangdingding  LV4 2020年1月3日
llu0000  LV2 2019年8月13日
mick_ming  LV1 2019年7月4日
liaoyouxiang  LV4 2019年6月26日
最近浏览更多
3334004690  LV10 1月15日
Kaiaahh  LV2 2023年12月30日
暂无贡献等级
summery  LV8 2023年4月25日
酒酒清欢  LV8 2023年2月26日
liangxiaolong  LV2 2022年11月8日
微信网友_6206233028890624  LV2 2022年11月5日
喃喵xxxx  LV6 2022年9月6日
akbar2020  LV9 2022年8月27日
Dreamable 2022年6月14日
暂无贡献等级
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友