Code example for Connection

Methods: commitprepareStatementrollbacksetAutoCommit

0
 
	public boolean set(BigDecimal qty, String string){
		setType(); 
		try { 
			conn = Database.getInstance().getConnection();
			conn.setAutoCommit(false);
			insertData(); 
			conn.commit();
			order.setId(id);
		} catch (SQLException e) {
			if (conn != null) {
				try { 
					conn.rollback();
				} catch (SQLException er) {
					er.printStackTrace();
					new ErrorDialog(er);
					return false; 
				} 
			} 
			new ErrorDialog(e);
			return false; 
		} finally { 
			try { 
				if (pssh != null ) pssh.close();
				if (pssd != null ) pssd.close();
				conn.setAutoCommit(true);
			} catch (SQLException e) {
				e.printStackTrace();
				new ErrorDialog(e);
				return false; 
			} 
		} 
		return true; 
	} 
 
	protected void setType() { 
	} 
 
	protected void insertData() throws SQLException { 
		pssh = conn.prepareStatement("" +
				"INSERT INTO " + type + "_header " +
				"	(ref_id, " + type + "_date, customer_id, actual) " +
				"	VALUES (?, ?, ?, ?) " + 
				"	RETURNING " + type + "_id "
				); 
Connect your IDE to all the code out there  Get Codota for Java