I'm having some issues to use the jar file ngdbc.jar. First of all, I need to do queries to a Hana database often, but since I'm developing with PHP and not able to get the proper drivers for it, I opt to use this Jar file. If I enter this connection command directly in terminal, got a successfull output:
java -jar ngdbc.jar -u '<dbuser>,<dbpassw>' -n <dbhost>:30015 -c 'SELECT * FROM "AE"."VI_CLIENTES" LIMIT 1'
But from the php script, calling the exec() function, cannot get an expected output ( info: the jar file is in the same directory as the php script)
<?php
class HanaConn
{
public function query($stringcommand)
{
$jarpath = "ngdbc.jar";
$user = "<dbuser>";
$pass = '<dbpassw>';
$host = '<dbhost>';
$command = "java -jar $jarpath -u '$user,$pass' -n $host:30015 -c '" . $stringcommand . "' ";
print_r( $command) ;
$result = exec($command, $outout, $resultcode);
print_r( json_encode([$outout, $result, $resultcode]) );
}
}
(new HanaConn)->query('SELECT * FROM "AE"."VI_CLIENTES" LIMIT 1');
?>
Output:
java -jar ngdbc.jar -u 'SAP,<passw>' -n <host>:30015 -c 'SELECT * FROM "AE"."VI_CLIENTES" LIMIT 1' [ [ "Usage: java -jar ngdbc.jar -h | --help | HELP", " to show this message.", "", " or java -jar ngdbc.jar -v | --version | VERSION", " to show the version information.", "", " or java -jar ngdbc.jar -g | --gui | GUI", " to run a GUI tool to configure trace settings.", "", " or java -jar ngdbc.jar -u [],[]", " [-n [:]]", " [-d ]", " [-i ]", " [-o =]", " [-w ]", " [-c ]", " to check whether a connection can be established or to execute", " a command.", "", " or java -jar ngdbc.jar -k ", " [-o =]", " [-w ]", " [-c ]", " to check whether a connection can be established or to execute", " a command using the secure store.", "", " or java -jar ngdbc.jar ", " Commands:", " TRACE ON | OFF", " Enables\/disables trace.", " TRACE FILENAME ", " Sets the name of the trace file. The driver adds a unique", " suffix to the trace file name.", " TRACE CONNECTIONS ON | OFF", " Enables\/disables trace of connects and disconnects.", " TRACE API ON | OFF", " Enables\/disables JDBC API trace.", " TRACE PACKET ON | OFF", " Enables\/disables trace of communication packets.", " TRACE DISTRIBUTION ON | OFF", " Enables\/disables trace of distribution features.", " TRACE STATISTICS ON | OFF", " Enables\/disables trace of sent\/received packet\/byte counts.", " TRACE CLEANERS ON | OFF", " Enables\/disables trace of cleaners\/finalizers for connections, statements, and result sets.", " TRACE DEBUG ON | OFF", " Enables\/disables trace of debug messages.", " TRACE SHOW PLAINTEXTCSE ON | OFF", " Enables\/disables trace of client-side encrypted values in plain-text.", " TRACE SHOW TIMESTAMPS ON | OFF", " Enables\/disables timestamps for each trace record.", " TRACE SHOW ELAPSEDTIMES ON | OFF", " Enables\/disables elapsed times for each JDBC API call and communication packet.", " TRACE SIZE [KB | MB | GB] | UNLIMITED", " Limits the size of the trace file to . Minimum size", " is 8192 bytes.", " TRACE STOP ON ERROR | OFF", " Stops tracing after the error is encountered or", " switches the trace stop feature off.", " TRACE FAILURE ACTION IGNORE | STDOUT | STDERR | EXCEPTION", " Selects the action in the event of a failure to open or write to the trace file.", " PERFORMANCETRACE ON | OFF", " Enables\/disables performance trace.", " PERFORMANCETRACE FILENAME", " Sets the name of the performance trace file. The driver", " adds a unique suffix to the trace file name.", " SHOW [ALL | TRACESETTINGS]", " Displays the current trace settings." ], " Displays the current trace settings.", 1 ]
It seems like not recognizing the parameters given.
I tried appending "2>&1" at the end of the command, as I read in some posts, but not working, maybe I missed something important
The query feature of the HANA jdbc driver is intended for testing purposes only. With PHP you are using a language that uses ODBC as a main database interface.
HANA comes with ODBC drivers and can be freely downloaded here
Why don't you use those ODBC drivers instead?