用JDBC读取postgresql record类型的数据

@Test
	public void testObjectAccess() throws Exception{
		TransJdbcTemplate lvTj = ContextHolder.getTransJdbcTemplate();
		Exception lvException= lvTj.doTransactionBatch(new TransCallback() {
			@Override
			public void onExecute(JdbcTemplate pvJt, NamedParameterJdbcTemplate pvNamedJt) throws Exception {
				List> lvRet=pvJt.queryForList("select *,row_to_row(f96_line,f96_order,f96_station) as rec from v96_qcdet_bylinejob where f96_date='24/Mar/2018'");
				PGobject lvObj =(PGobject) lvRet.get(0).get("rec");
				String lvVal=lvObj.getValue();
				Assert.assertNotNull(lvVal);
			}		
		});
		if (lvException!=null)
			  throw lvException;
	}


查了很久,没发现有PGRecord之类的对应class,只有用PGobject这个通用的来接收record类型的数据了. 上面例子lvVal返回的数值为"(NB01,JB049082,AFT)".

你可能感兴趣的:(postgreSQL,语言设计,java)