1.oracle driver
oracle.jdbc.OracleDriver
2.mysql driver
com.mysql.jdbc.Driver
jdbc:mysql://127.0.0.1:3306/juggle?useSSL=false&characterEncoding=utf-8
3.Oracle driver :常用sql语句:
-
查询目前所在的数据库: select name from v$database;
HELOWIN
-
查看数据库结构字段 desc v$databases;
-
怎样查看哪些用户拥有SYSDBA、SYSOPER权限: select * from V$PWFILE_USERS
-
查看当前数据库连接用户 Show user;
-
进入test数据库 database test;
-
查看当前库的所有数据表: select TABLE_NAME from all_tables;
-
查询表字段 desc all_tables;
-
更新数据库用户的密码 alter user sys indentified by test;
alter user system indentified by test;
-
增加数据库用户 create user test11 identified by test default tablespace users Temporary TABLESPACE Temp;
-
用户授权 grant connect,resource,dba to test11;
grant sysdba to test11;
-
建表语句 create table Person(id int,name varchar(16));
-
插入语句 insert into Person values(1,'one');
insert into Person values(2,'er');
insert into Person values(3,'san');
insert into Person values(4,'si');
insert into Person values(5,'wu');
insert into Person values(6,'liu');
insert into Person values(7,'qi');
insert into Person values(8,'ba');
insert into Person values(9,'jiu');
insert into Person values(10,'shi');
insert into Person values(11,'shiyi');
insert into Person values(12,'shier');
insert into Person values(13,'shisan');
insert into Person values(14,'shisi');
insert into Person values(15,'shiwu');
3.状态存储到minio 中,相关API的使用:
public static void isExist() throws Exception {
boolean exists = minioClient.bucketExists(BucketExistsArgs.builder().bucket(bucket).build());
if (!exists) {
minioClient.makeBucket(MakeBucketArgs.builder().bucket(bucket).build());
System.out.println("create bucket");
} else {
System.out.println("bucket is exist");
}
}
public static void putObject(String addressPath) throws Exception {
InputStream inputStream = new FileInputStream(addressPath);
PutObjectArgs build = PutObjectArgs.builder()
.bucket(bucket)
.stream(inputStream, 266, -1)
.object(addressPath).build();
minioClient.putObject(build);
}
public static void listObject() throws Exception {
ListObjectsArgs build = ListObjectsArgs.builder().bucket(bucket).recursive(true).build();
Iterator<Result<Item>> iterator = minioClient.listObjects(build).iterator();
while (iterator.hasNext()) {
System.out.println(iterator.next().get().objectName());
}
}
public static void getObjectContent() throws Exception {
GetObjectArgs build = GetObjectArgs.builder()
.bucket(bucket)
.object(addressPath)
.build();
String line;
StringBuilder sb = new StringBuilder();
InputStream inputStream = minioClient.getObject(build);
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
while ((line = bufferedReader.readLine()) != null) {
sb.append(line).append("\n");
}
System.out.println(sb.toString());
}
public static void selectObjectContent() throws Exception {
String sqlExpression = "select name from S3Object where name ='jack' limit 5";
InputSerialization is = new InputSerialization(CompressionType.NONE, true,
null, ',', FileHeaderInfo.USE, null, '\\', '\n');
OutputSerialization os = new OutputSerialization(',', null, null, QuoteFields.ASNEEDED, '\n');
HashMap<String, String> map = new HashMap<>();
map.put("name", "jack");
SelectResponseStream stream =
minioClient.selectObjectContent(
SelectObjectContentArgs.builder()
.bucket(bucket)
.object(addressPath)
.sqlExpression(sqlExpression)
.extraQueryParams(map)
.inputSerialization(is)
.outputSerialization(os)
.requestProgress(true)
.build());
byte[] buf = new byte[512];
int bytesRead = stream.read(buf, 0, buf.length);
System.out.println(new String(buf, 0, bytesRead, StandardCharsets.UTF_8));
Stats stats = stream.stats();
System.out.println("bytes scanned: " + stats.bytesScanned());
System.out.println("bytes processed: " + stats.bytesProcessed());
System.out.println("bytes returned: " + stats.bytesReturned());
stream.close();
}
public static void deleteObject(String addressPath) throws Exception {
minioClient.removeObject(
RemoveObjectArgs.builder().bucket(bucket).object(addressPath).build());
}
public static void composeObject() throws Exception {
List<ComposeSource> sourceObjectList = new ArrayList<ComposeSource>();
sourceObjectList.add(
ComposeSource.builder().bucket(bucket).object(addressPath1).build());
sourceObjectList.add(
ComposeSource.builder().bucket(bucket).object(addressPath2).build());
ObjectWriteResponse objectWriteResponse = minioClient.composeObject(
ComposeObjectArgs.builder()
.bucket(bucket)
.object(addressPathCount)
.sources(sourceObjectList)
.build());
System.out.println(objectWriteResponse.etag());
}
public static void uploadObject(String addressPath) throws Exception {
minioClient.uploadObject(UploadObjectArgs.builder().bucket(bucket).object(addressPath)
.filename("/Users/yingjiezhang/test1.csv").build());
}
public static void setLockObject() throws Exception{
ObjectLockConfiguration config = new ObjectLockConfiguration(RetentionMode.COMPLIANCE, new RetentionDurationDays(100));
minioClient.setObjectLockConfiguration(
SetObjectLockConfigurationArgs.builder()
.bucket(bucket)
.config(config)
.build());
}
|