contract PostgreSQLSample{ function onCreate(){ Global.dbArg= "jdbc:postgresql://127.0.0.1:5432/huaqiancai"; } export function selectStudent(arg){ var conn = org.test.PostgreSQLUtil.connect(Global.dbArg); if (conn!=undefined && !conn.isClosed()){ print("successfully connected"); } else return "connect failed"; var sql = "select * from student;"; var statement = conn.createStatement(); var resultSet = statement.executeQuery(sql); ret = []; var meta = resultSet.getMetaData(); for (;resultSet.next();){ var line = { }; for (var j=1;j<=meta.getColumnCount();j++){ line[meta.getColumnName(j)] = resultSet.getString(j); } ret.push(line); } return JSON.stringify(ret); } }