Orientdb connection not closing - orientdb

I am using Orientdb 2.2.12.
This below is single source from where I am getting Connection instance
public static synchronized Connection getOrientDbConnection(String appName)
{
try {
// address of Db Server
OServerAdmin serverAdmin = new OServerAdmin
("remote:" + ip + ":" + port + "/"
+ appName).connect("root", "1234");
if (serverAdmin.existsDatabase())
{
serverAdmin.close();
Properties info = new Properties();
info.put("user", "root");
info.put("password", "1234");
Connection conn = (OrientJdbcConnection) DriverManager.getConnection("jdbc:orient:remote:" + ip + ":" + port + "/"
+ appName, info);
//System.out.println(" Database Connection instance returned for : " + appName + " for thread ID : " + Thread.currentThread().getId());
return conn;
}
else
{
// "Type_Of_Db", "Type_Of_Storage"
serverAdmin.createDatabase("GRAPH", "plocal");
serverAdmin.close();
OrientGraphFactory graphFactory = new OrientGraphFactory(
"remote:" + ip + ":" + port + "/" + appName);
/**
* ####################### Do This only Ones-Per-Database #####################
* 1. Create index with unique field
* #name = unique index will be created only one time for a particular database
*
*
*/
OrientGraphNoTx graph = graphFactory.getNoTx();
graph.createKeyIndex("name", Vertex.class, new Parameter<String, String>("type", "UNIQUE"));
// shutdown the graph which created Index immediately
graph.commit();
graph.shutdown();
// close all db pools
graphFactory.close();
try
{
Properties info = new Properties();
info.put("user", "root");
info.put("password", "pcp");
Connection conn = (OrientJdbcConnection) DriverManager.getConnection("jdbc:orient:remote:" +ip + ":" + port + "/" + appName, info);
//System.out.println(" Database created and Connection instance return for : " + appName + " for thread ID : " + Thread.currentThread().getId());
return conn;
} catch (Exception e) {
//System.out.println("Problem creating database or getting connection from database " + " for thread ID : " + Thread.currentThread().getId() + e.getMessage());
e.getMessage();
return null;
}
}
}
catch(Exception e)
{
e.getMessage();
}
return null;
}
My use-case is creating :-
vertexes
edges
update vertex, edges etc..
App.java
Connection conn = DB.getOrientDbConnection(String appName)
// create vertex
// create edges
conn.commit()
conn.close();
What problems I am facing ?
Even after program finishes and conn.close() done, JConsole showing Orientdb connection still active.
Name: OrientDB <- Asynch Client (/192.168.1.11:4424)
State: RUNNABLE
Total blocked: 0 Total waited: 136
Stack trace:
java.net.SocketInputStream.socketRead0(Native Method)
java.net.SocketInputStream.socketRead(Unknown Source)
java.net.SocketInputStream.read(Unknown Source)
java.net.SocketInputStream.read(Unknown Source)
java.io.BufferedInputStream.fill(Unknown Source)
java.io.BufferedInputStream.read(Unknown Source)
- locked java.io.BufferedInputStream#1780dcd
java.io.DataInputStream.readByte(Unknown Source)
com.orientechnologies.orient.enterprise.channel.binary.OChannelBinary.readByte(OChannelBinary.java:68)
com.orientechnologies.orient.client.binary.OChannelBinaryAsynchClient.beginResponse(OChannelBinaryAsynchClient.java:189)
com.orientechnologies.orient.client.binary.OAsynchChannelServiceThread.execute(OAsynchChannelServiceThread.java:51)
com.orientechnologies.common.thread.OSoftThread.run(OSoftThread.java:77)
Is this a bug or I am doing something wrong?

If your server is running you will see that in JConsole.

Related

Flink SQL Client connect to secured kafka cluster

I want to execute a query on Flink SQL Table backed by kafka topic of secured kafka cluster. I'm able to execute the query programmatically but unable to do the same through Flink SQL client. I'm not sure on how to pass JAAS config (java.security.auth.login.config) and other system properties through Flink SQL client.
Flink SQL query programmatically
private static void simpleExec_auth() {
// Create the execution environment.
final EnvironmentSettings settings = EnvironmentSettings.newInstance()
.inStreamingMode()
.withBuiltInCatalogName(
"default_catalog")
.withBuiltInDatabaseName(
"default_database")
.build();
System.setProperty("java.security.auth.login.config","client_jaas.conf");
System.setProperty("sun.security.jgss.native", "true");
System.setProperty("sun.security.jgss.lib", "/usr/libexec/libgsswrap.so");
System.setProperty("javax.security.auth.useSubjectCredsOnly","false");
TableEnvironment tableEnvironment = TableEnvironment.create(settings);
String createQuery = "CREATE TABLE test_flink11 ( " + "`keyid` STRING, " + "`id` STRING, "
+ "`name` STRING, " + "`age` INT, " + "`color` STRING, " + "`rowtime` TIMESTAMP(3) METADATA FROM 'timestamp', " + "`proctime` AS PROCTIME(), " + "`address` STRING) " + "WITH ( "
+ "'connector' = 'kafka', "
+ "'topic' = 'test_flink10', "
+ "'scan.startup.mode' = 'latest-offset', "
+ "'properties.bootstrap.servers' = 'kafka01.nyc.com:9092', "
+ "'value.format' = 'avro-confluent', "
+ "'key.format' = 'avro-confluent', "
+ "'key.fields' = 'keyid', "
+ "'value.fields-include' = 'EXCEPT_KEY', "
+ "'properties.security.protocol' = 'SASL_PLAINTEXT', 'properties.sasl.kerberos.service.name' = 'kafka', 'properties.sasl.kerberos.kinit.cmd' = '/usr/local/bin/skinit --quiet', 'properties.sasl.mechanism' = 'GSSAPI', "
+ "'key.avro-confluent.schema-registry.url' = 'http://kafka-schema-registry:5037', "
+ "'key.avro-confluent.schema-registry.subject' = 'test_flink6', "
+ "'value.avro-confluent.schema-registry.url' = 'http://kafka-schema-registry:5037', "
+ "'value.avro-confluent.schema-registry.subject' = 'test_flink4')";
System.out.println(createQuery);
tableEnvironment.executeSql(createQuery);
TableResult result = tableEnvironment
.executeSql("SELECT name,rowtime FROM test_flink11");
result.print();
}
This is working fine.
Flink SQL query through SQL client
Running this giving the following error.
Flink SQL> CREATE TABLE test_flink11 (`keyid` STRING,`id` STRING,`name` STRING,`address` STRING,`age` INT,`color` STRING) WITH('connector' = 'kafka', 'topic' = 'test_flink10','scan.startup.mode' = 'earliest-offset','properties.bootstrap.servers' = 'kafka01.nyc.com:9092','value.format' = 'avro-confluent','key.format' = 'avro-confluent','key.fields' = 'keyid', 'value.avro-confluent.schema-registry.url' = 'http://kafka-schema-registry:5037', 'value.avro-confluent.schema-registry.subject' = 'test_flink4', 'value.fields-include' = 'EXCEPT_KEY', 'key.avro-confluent.schema-registry.url' = 'http://kafka-schema-registry:5037', 'key.avro-confluent.schema-registry.subject' = 'test_flink6', 'properties.security.protocol' = 'SASL_PLAINTEXT', 'properties.sasl.kerberos.service.name' = 'kafka', 'properties.sasl.kerberos.kinit.cmd' = '/usr/local/bin/skinit --quiet', 'properties.sasl.mechanism' = 'GSSAPI');
Flink SQL> select * from test_flink11;
[ERROR] Could not execute SQL statement. Reason:
java.lang.IllegalArgumentException: Could not find a 'KafkaClient' entry in the JAAS configuration. System property 'java.security.auth.login.config' is /tmp/jaas-6309821891889949793.conf
There is nothing in /tmp/jaas-6309821891889949793.conf except the following comment
# We are using this file as an workaround for the Kafka and ZK SASL implementation
# since they explicitly look for java.security.auth.login.config property
# Please do not edit/delete this file - See FLINK-3929
SQL client run command
bin/sql-client.sh embedded --jar flink-sql-connector-kafka_2.11-1.12.0.jar --jar flink-sql-avro-confluent-registry-1.12.0.jar
Flink cluster command
bin/start-cluster.sh
How to pass this java.security.auth.login.config and other system properties (that I'm setting in the above java code snippet), for SQL client?
flink-conf.yaml
security.kerberos.login.use-ticket-cache: true
security.kerberos.login.principal: XXXXX#HADOOP.COM
security.kerberos.login.use-ticket-cache: false
security.kerberos.login.keytab: /path/to/kafka.keytab
security.kerberos.login.principal: XXXX#HADOOP.COM
security.kerberos.login.contexts: Client,KafkaClient
I haven't really tested whether this solution is feasible, you can try it out, hope it will help you.

Error compiling insert into: No column named ID

Been testing some answers found but still no effect. What am I missing? Please see below.
String createTableCommand = "CREATE TABLE " + TABLE_NAME + "("
+ COL_USER_ID +" INTEGER PRIMARY KEY,"
+ COL_USER_FULL_NAME + " TEXT NOT NULL,"
+ COL_USER_PASSWORD + " TEXT NOT NULL)";
#Override
public void onCreate(SQLiteDatabase db) {
db.execSQL(createTableCommand);
}
public void insertUsers(User user){
SQLiteDatabase db = this.getReadableDatabase();
ContentValues values = new ContentValues();
values.put(COL_USER_ID,user.getid());
values.put(COL_USER_FULL_NAME,user.getUserFullName());
values.put(COL_USER_PASSWORD,user.getPassword());
db.insert(TABLE_NAME,"",values);
Log.d("Inside insertUsers(): ","INSERTED "+user.getid() + " " +user.getUserFullName() + " " +user.getPassword());
}
Error: E/SQLiteLog: (1) table User has no column named ID
10-30 21:04:09.791 15860-15860/com.bustracker.usc.uscbt E/SQLiteDatabase: Error inserting ID=15200002 PASSWORD=shansay FULLNAME=Shansay
android.database.sqlite.SQLiteException: table User has no column named ID (code 1): , while compiling: INSERT INTO User(ID,PASSWORD,FULLNAME) VALUES (?,?,?)
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:889)
at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:500)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31)
at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1472)
at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1343)
at com.bustracker.usc.uscbt.com.usc.tc.dbhandler.UserDbHandler.insertUsers(UserDbHandler.java:62)
at com.bustracker.usc.uscbt.com.bustracker.com.uscbt.model.UserCRUD$1.onClick(UserCRUD.java:39)
at android.view.View.performClick(View.java:5637)
at android.view.View$PerformClick.run(View.java:22429)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

Error while replicating couch db

When replcating couch db from remote system to local system through _changes feed, I get this error
`05-04 19:19:48.089: ERROR/CouchDB(984): [error] [<0.115.0>] Error in replication `a4b53e74a33b773bbca688073b6bbe0d+continuous` (triggered by document `cloud2airline`): {worker_died,<0.532.0>,
{process_died,<0.547.0>,
{function_clause,
[{string,tokens1,[undefined,";",[]]},
{mochiweb_util,parse_header,1},
{couch_httpd,get_boundary,1},
{couch_httpd,parse_multipart_request,3},
{couch_api_wrap,'-open_doc_revs/6-fun-1-',4},
{couch_api_wrap_httpc,process_stream_response,5},
{couch_api_wrap,'-open_doc_revs/6-fun-2-',4}]}}}
Restarting replication in 5 seconds.`
Node js proxy code
`'use strict';
/*!
* Middleware for forwarding a request to CouchDB.
*/
/**
* Module dependencies.
*/
var httpProxy = require('http-proxy'),
util = require('./util');
module.exports = function(couch) {
var proxy = new httpProxy.HttpProxy(couch),
couchTarget = couch.target;
httpProxy.setMaxSockets(200);
return function(req, res, next) {
req.headers['host'] = couchTarget.host + ':' + couchTarget.port;
req.headers['authorization'] = couch.credentials;
req.headers['x-forwarded-ssl'] = util.isSecureForwardedRequest(req);
var forwardedFor = req.headers['x-forwarded-for'];
req.headers['x-real-ip'] = forwardedFor
? forwardedFor.split(',',1)[0]
: req.connection.remoteAddress;
req.url = couch.path + req.url;
console.log(req.headers['x-forwarded-for']);
console.log(req.headers['x-real-ip']);
console.log(req.headers['x-forwarded-ssl'] );
console.log(couchTarget.host + ":" + couchTarget.port + req.url);
return proxy.proxyRequest(req, res);
}
}`

java.sql.SQLException: Network error IOException: Connection timed out: connect

I have installed SQL Server 2012 Express in my laptop and tried to run a sample java program as follows:
import java.sql.*;
public class Ex2 {
Connection con;
Statement st;
ResultSet rs;
public Ex2(String query){
System.out.println("IN Const1");
try{
System.out.println("IN try");
Class.forName("net.sourceforge.jtds.jdbc.Driver");
String dbName = "HOME";
String user = "sa";
String password = "JUL#2012";
//the name of my SQL SERVER 2005 instance
String SqlServerInstance = "SQLEXPRESS";
String url = "jdbc:jtds:sqlserver://localhost:1433";
url = url + "/" + dbName;
url = url + ";" + SqlServerInstance;
con = DriverManager.getConnection(url, user, password);
System.out.println("nach DriverManager");
st = con.createStatement();
st.executeQuery(query);
rs = st.getResultSet();
while ( rs.next() ){
System.out.println(rs.getString(0));
System.out.println(rs.getString(1));
System.out.println(rs.getString(2));
System.out.println(rs.getString(3));
}
}
catch(Exception e){
e.printStackTrace();
System.out.println("Exception: " + e.getMessage());
}
}
public static void main(String[] argv){
System.out.println("IN MAIN");
Ex2 test = new Ex2("SELECT * FROM HOME.dbo.employee;");
}
}*
and getting the following error log in the console:
java.sql.SQLException: Network error IOException: Connection timed out: connect
at net.sourceforge.jtds.jdbc.ConnectionJDBC2.<init>(ConnectionJDBC2.java:410)
at net.sourceforge.jtds.jdbc.ConnectionJDBC3.<init>(ConnectionJDBC3.java:50)
at net.sourceforge.jtds.jdbc.Driver.connect(Driver.java:184)
at java.sql.DriverManager.getConnection(DriverManager.java:525)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
at Ex2.<init>(Ex2.java:22)
at Ex2.main(Ex2.java:43)
Caused by: java.net.ConnectException: Connection timed out: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:516)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at net.sourceforge.jtds.jdbc.SharedSocket.createSocketForJDBC3(SharedSocket.java:307)
at net.sourceforge.jtds.jdbc.SharedSocket.<init>(SharedSocket.java:257)
at net.sourceforge.jtds.jdbc.ConnectionJDBC2.<init>(ConnectionJDBC2.java:311)
Exception: Network error IOException: Connection timed out: connect
... 6 more
When I checked the sql server configuration manager the services SQL Server and SQL Server Browser are running.
I have been googling for the last two days and struggle to fix this issue and couldn't. So please help me.

FileMaker 10 Pro Insert data by Asp.Net

I am trying to insert the data in FM but get the parse error serached number of fourms with no luck.
ERROR [HY000] [DataDirect][ODBC SequeLink driver][ODBC Socket][DataDirect][ODBC FileMaker driver][FileMaker]Parse Error in SQL
enter code here
StringBuilder sbAddBarcode = new StringBuilder();
sbAddBarcode.Append("insert into BarCode (PONumber,Description,Model,[Serial Number])");
sbAddBarcode.Append("values");
sbAddBarcode.Append(" ("+ barcode.PONumber + ",");
sbAddBarcode.Append(" '" + barcode.Description +"',");
sbAddBarcode.Append(" '" + barcode.ModelNumber +"')");
//sbAddBarcode.Append(" '" + barcode.SerialNumber +"')");
fmCommand = new OdbcCommand(sbAddBarcode.ToString(), fmcon);
fmCommand.CommandType = CommandType.Text;
fmCommand.Connection = fmcon;
try
{
fmcon.Open();
fmCommand.ExecuteNonQuery();
}
catch (OdbcException oe)
{
throw new Exception(oe.Message);
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
finally
{
fmcon.Close();
}
Echo your sbAddBarcode value. The SQL you're building does look to be invalid.