gbase 8a JDBC连接测试

package com.jdbclearn.gbase8a.dataload;


import java.sql.*;


public class TestConnection {
public static void main(String args[]) {


try {
            //gbase.url=jdbc:gbase://127.0.0.1 
String url = "jdbc:gbase://192.168.x.y:5258/testdb";
String user = "testuser";
String passwd = "**********";


Connection connect = DriverManager.getConnection(url, user, passwd);
// 连接URL为 jdbc:gbase//服务器地址/数据库名 ,后面的2个参数分别是登陆用户名和密码


System.out.println("Success connect Gbase 8a server!");
Statement stmt = connect.createStatement();
ResultSet rs = stmt.executeQuery("select * from T1");
// user 为你表的名称
while (rs.next()) {
System.out.println(rs.getString("name"));
}
} catch (Exception e) {
System.out.print("get data error!");
e.printStackTrace();
}
}
}

你可能感兴趣的:(Java,EE)