Skip to content
This repository has been archived by the owner on Oct 3, 2020. It is now read-only.

Commit

Permalink
working on a new DB system
Browse files Browse the repository at this point in the history
  • Loading branch information
fulton committed Apr 27, 2020
1 parent ad34354 commit 54006e0
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ dependencies {
compile group: 'org.apache.opennlp', name: 'opennlp-tools', version: '1.9.2'
compile group: 'com.microsoft.sqlserver', name: 'mssql-jdbc', version: '8.3.0.jre14-preview'
compile group: 'com.microsoft.azure', name: 'azure-cosmosdb', version: '2.6.7'
compile group: 'org.mongodb', name: 'mongo-java-driver', version: '3.12.3'

implementation 'com.google.code.gson:gson:2.8.6'
// https://mvnrepository.com/artifact/postgresql/postgresql
Expand Down
36 changes: 33 additions & 3 deletions src/main/java/com/andromeda/araserver/util/DatabaseClient.kt
Original file line number Diff line number Diff line change
@@ -1,18 +1,48 @@
package com.andromeda.araserver.util

import com.mongodb.MongoClient
import com.mongodb.MongoClientSettings
import com.mongodb.MongoCredential
import com.mongodb.ServerAddress
import com.mongodb.client.MongoClients
import com.mongodb.connection.ClusterSettings
import com.mongodb.connection.SslSettings
import java.util.*
import kotlin.collections.ArrayList


object DatabaseClient {
val address:String = System.getenv("dblink")
val password = System.getenv("dbpassword")
val dbname = System.getenv("dbname")
val collectionName = System.getenv("collname")
val cred = MongoCredential.createCredential("ara", dbname, password.toCharArray())
var settings = MongoClientSettings.builder()
.credential(cred)
.applyToSslSettings { builder: SslSettings.Builder ->
builder.enabled(
true
)
}
.applyToClusterSettings { builder: ClusterSettings.Builder ->
builder.hosts(
Arrays.asList(ServerAddress(address))
)
}
.build()
val client = MongoClients.create(settings)
val database = client.getDatabase(dbname)
val collection = database.getCollection(collectionName)
fun new(){

}
fun edit(){

}
fun <T>get():T{
fun <T>get(userId:String, id:String):T{

}
fun <T>getAll():ArrayList<T>{
fun <T>getAll(userId:String):ArrayList<T>{

}

}

0 comments on commit 54006e0

Please sign in to comment.