本文整理汇总了Java中org.h2.jdbc.JdbcSQLException.printStackTrace方法的典型用法代码示例。如果您正苦于以下问题:Java JdbcSQLException.printStackTrace方法的具体用法?Java JdbcSQLException.printStackTrace怎么用?Java JdbcSQLException.printStackTrace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.h2.jdbc.JdbcSQLException
的用法示例。
在下文中一共展示了JdbcSQLException.printStackTrace方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createTable
import org.h2.jdbc.JdbcSQLException; //导入方法依赖的package包/类
private void createTable() {
try {
con = this.dataSource.getConnection();
pstm = con.prepareStatement("CREATE TABLE IF NOT EXISTS device_location.gateway "
+ "(id BIGINT AUTO_INCREMENT PRIMARY KEY, longitude DECIMAL(9, 7), latitude DECIMAL(10, 7))");
pstm.executeUpdate();
System.out.println("'Gateway' table created");
} catch (JdbcSQLException e) {
e.printStackTrace(System.out);
System.out.println("Table already exists");
} catch (SQLException ex) {
ex.printStackTrace(System.out);
System.out.println("Table ERROR");
}
}
示例2: selectOne
import org.h2.jdbc.JdbcSQLException; //导入方法依赖的package包/类
public Location selectOne(String id) {
ResultSet rs_local;
Location location;
try {
con = this.dataSource.getConnection();
pstm = con.prepareStatement("SELECT * FROM device_location.gateway WHERE id=?;");
pstm.setString(1, id);
rs_local = pstm.executeQuery();
if (rs_local.next()) {
location = new Location();
location.setId(rs_local.getLong("id"));
location.setLatitude(rs_local.getFloat("latitude"));
location.setLongitude(rs_local.getFloat("longitude"));
return location;
} else {
return null;
}
} catch (JdbcSQLException e) {
e.printStackTrace(System.out);
return null;
} catch (SQLException ex) {
ex.printStackTrace(System.out);
return null;
}
}
示例3: selectAll
import org.h2.jdbc.JdbcSQLException; //导入方法依赖的package包/类
public ArrayList<Location> selectAll() {
ResultSet rs_local;
ArrayList<Location> ar = new ArrayList();
try {
con = this.dataSource.getConnection();
pstm = con.prepareStatement("SELECT * FROM device_location.gateway");
rs_local = pstm.executeQuery();
while (rs_local.next()) {
Location loc = new Location();
//dm.setId(rs_local.getLong("id"));
//dm.setLatitude(rs_local.getFloat("latitude"));
//dm.setLongitude(rs_local.getFloat("longitude"));
ar.add(loc);
}
return ar;
} catch (JdbcSQLException e) {
e.printStackTrace(new PrintStream(System.err));
return null;
} catch (SQLException ex) {
ex.printStackTrace(new PrintStream(System.err));
return null;
}
}
示例4: createSchema
import org.h2.jdbc.JdbcSQLException; //导入方法依赖的package包/类
private void createSchema() {
try {
con = this.dataSource.getConnection();
pstm = con.prepareStatement("CREATE SCHEMA IF NOT EXISTS device_location");
pstm.executeUpdate();
System.out.println("Schema Created");
} catch (JdbcSQLException e) {
e.printStackTrace(System.out);
System.out.println("Schema already exists");
} catch (SQLException ex) {
ex.printStackTrace(System.out);
System.out.println("Schema ERROR");
}
}