package com.jdbclearn.gbase8a.dataload;
import java.sql.*;
?
public class TestConnection {
public static void main(String args[]) {
try {
String url = "jdbc:gbase://192.168.1.1:8521/testdb";
String user = "test";
String passwd = "test123";
?
Connection connect = DriverManager.getConnection(url, user, passwd);
// 連接URL為 jdbc:gbase//服務器地址/數(shù)據(jù)庫名 ,后面的2個參數(shù)分別是登 陸用戶名和密碼
//testdb 數(shù)據(jù)庫實例
?
System.out.println("Success connect Gbase 8a server!");
Statement stmt = connect.createStatement();
ResultSet rs = stmt.executeQuery("select * from test");
// user 為你表的名稱
while (rs.next()) {
System.out.println(rs.getString("name"));
}
} catch (Exception e) {
System.out.print("get data error!");
e.printStackTrace();
}
}
}
?
?
?
?
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//服務器地址/數(shù)據(jù)庫名 ,后面的2個參數(shù)分別是登陸用戶名和密碼
?
?
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();
}
}
}
?
?
?
?
?
本文摘自 :https://www.cnblogs.com/