gRPC Java Database Client Accessing
Use IntelliJ IDEA CE
build maven (proto and other pkgs)
run package at maven
Run backend accessor (run manually or in a docker container)
Add this module into your project
git submodule add https://github.com/mtvy/grpc_java_database_accessing.git
Import module like:
import java_client .src .main .java .database_client .Client
public class ClientTest extends TestCase {
final String DB_HOST = "postgres://postgres:postgres@0.0.0.0:5432/postgres" ;
public void testApp ()
{
Client client = new Client ("0.0.0.0:8080" );
System .out .println ("INSERTING {url: 'Hello', name: 'World'} into [qrcodes_tb]\n " +
client .insertDb ("qrcodes_tb" , "url, name" , "'Hello', 'World'" , DB_HOST ));
System .out .println ("GETTING from [qrcodes_tb] \" WHERE url='Hello'\" \n " +
client .getDb ("*" , "qrcodes_tb" , "WHERE url='Hello'" , DB_HOST ));
System .out .println ("GETTING from [qrcodes_tb] \" WHERE url='Hello'\" \n " +
client .deleteDb ("qrcodes_tb" , "WHERE url='Hello'" , DB_HOST ));
}
}
INSERTING {url: ' Hello' , name: ' World' } into [qrcodes_tb]
status: " ok"
GETTING from [qrcodes_tb] " WHERE url='Hello'"
status: " ok"
data: " [[23437,\" Hello\" ,null,null,\" World\" ,null,null,null,null],[23438,\" Hello\" ,null,null,\" World\" ,null,null,null,null]]"
GETTING from [qrcodes_tb] " WHERE url='Hello'"
status: " ok"