import java.sql.*;
public class seljson {
private static String URL_STRING =
"jdbc:gbasedbt-sqli://192.168.69.219:9022/ttdb:" +
"GBASEDBTSERVER=gbase01;NEWCODESET=GB18030,GB18030-2000,5488;" +
"DB_LOCALE=zh_cn.GB18030-2000;CLIENT_LOCALE=zh_cn.GB18030-2000;";
private static String USER = "gbasedbt";
private static String PASSWORD = "XXXX";
public static void main( String[] args)
throws SQLException, ClassNotFoundException {
Class.forName( "com.gbasedbt.jdbc.IfxDriver" );
try {
Connection conn = DriverManager.getConnection(URL_STRING, USER, PASSWORD);
//Statement stmt = conn.createStatement();
//ResultSet rs1 = stmt.executeQuery("select * from tabjson");
//查询tabjson数据表里的数据
String sqls="select * from tabjson where col1=? ";
PreparedStatement stmt = conn.prepareStatement(sqls);
stmt.setInt(1,100);
ResultSet rs1 = stmt.executeQuery();
while ( rs1.next() ) {
//输出查询结果
//System.out.println( rs1.getInt(1) +"\t"+rs1.getString(2));
int col1=rs1.getInt(1);
String col2=rs1.getString(2);
System.out.println(col1+"\t"+col2);
//System.out.println( rs1.getString(2) );
//System.out.println( "" );
}
rs1.close();
stmt.close();
conn.close();
} catch( Exception e) {
e.printStackTrace();
}
return;
}
}
JAVA查询demo
最新推荐文章于 2022-12-27 14:18:54 发布