Java exception in Mathematica while trying to access MS Access - wolfram-mathematica

I'm trying to make "Wolfram Mathematica" to manipulate a *.accdb file. I already established a connection (to a file with an empty "table1"):
Needs["DatabaseLink`"]
conn = OpenSQLConnection[]
Source: http://reference.wolfram.com/language/DatabaseLink/ref/SQLInsert.html
It works fine. If I make:
SQLSelect[conn, "table1"]
I get
{}
Now I want to create a table with:
SQLCreateTable[conn,
SQLTable["TEST"], {SQLColumn["COL1", "DataTypeName" -> "INTEGER"],
SQLColumn["COL2", "DataTypeName" -> "DOUBLE"]}];
I get the exception:
Java::excptn: A Java exception occurred:
java.lang.NullPointerException at
net.ucanaccess.jdbc.UcanaccessPreparedStatement.clearParameters(UcanaccessPreparedStatement.java:214)
at
com.wolfram.databaselink.SQLStatementProcessor.processSQLStatement(SQLStatementProcessor.java:311).
Sorry for bad english (but I tried).
Thank you guys!

I think you need to specify a database, e.g.
conn = OpenSQLConnection["demo"]

Sometimes if you "open the same connection" many times Mathematica doesn't understand what to do. Just
Quit
the Kernel and re-establish the connection. SQL will work properly.

Related

solr jdbc throws and exception as if something is wrong within implementation there

I am trying to check the solr jdbc driver.
It seems to be working only with DbVisualizer & squirrelSQL.
As it is totally undocumented (properties, etc.) I've no idea what is the issue, but I keep on getting some weird error :
java.sql.SQLException which results from java.io.IOException which
results from org.noggit.JSONParser$ParserException: JSON Parse Error
char=<
It seems like internally something is going wrong there, as the engine expects JSON and receives XML.
The code is super straight forward :
Class.forName("org.apache.solr.client.solrj.io.sql.DriverImpl");
Connection conn = DriverManager.getConnection("jdbc:solr://zootest01:2181/?collection=mycol");
Statement stat = conn.createStatement();
ResultSet rs = stat.executeQuery("select item_id from mycol limit 10");
The above is the most straightforward code for Java using JDBC.
The executeQuery will always throw an exception.
What is more weird is that tools like DBeaver has the same problem exactly.
I couldn't find any explanation to this behavior, unless something in the implementation is somehow hard-coded to the above 2 specific tools.

Set Properties in Toad Data Point Fails

I am using Toad Data Point V4.0 to connect to Hive. I try to set below properties using Toad.
set hive.input.format=org.apache.hadoop.hive.ql.io.BucketizedHiveInputFormat;
set hive.optimize.bucketmapjoin=true;
set hive.optimize.bucketmapjoin.sortedmerge=true;
While I can set these properties via Beeline, TOAD throws below error when running above set commands.
[Hortonworks][Hardy] (80) Syntax or semantic analysis error thrown in server while executing query. Error message from server: Error while processing statement: Cannot modify input.format at runtime. It is not in list of params that are allowed to be modified at runtime
Wondering if I have to set these properties somewhere in connection setup or not. Appreciate your input.
We've found a very similar issue with DBVis on Hive.
DBVis is stripping the ‘hive.’ off of commands like “set hive.mapred.mode=strict”. It then checks hive’s list of parameters allowed to be set at runtime for the parameter: “mapred.mode” instead of “hive.mapred.mode”. Since it does not find the parameter, it throws and error.
If we preface the parameter by a second “hive.” (for example, “hive.hive.mapred.mode=strict”) DBVis appears to strips off the first “hive.”. It then finds the stripped version as allowed and sends the stripped version to hive where is executes fine.
NB: This only seems to affect parameters beginning with "hive.".

Delphi 7 how to load data from an ADOQuery to a DBChart at runtime

Im having the following problem with Delphi 7.
I try to use a DBchart to represent some data with a line diagram from a database.
I want the data to be loaded from an ADOQuery that gets activated at runtime thought. I can do it without problem with a query that has a static SQL value, but i find problems at setting the datasource at runtime.
I try to use
dbchart1.series[1].datasource:=ADOQuery3;
After i have created series1, but i get a "list index out of bounds" error.
Am i using the wrong command? I tried several others but failed.
Anyone can give some help with this?
Solved it with the following (after creating series1 at the DBGrid)
with series1 do
begin
datasource:=ADOquery;
xlabelssource:='field1';
YValues.Valuesource:='field2';
checkdatasource;
end;

Mongo::OperationFailure - need to login when using from_uri

My goal is to connect with my heroku/mongolab database but I keep getting this error:
Mongo::OperationFailure at /mongotest/a/b
: need to login
file: networking.rb
location: send_message_with_gle
line: 89
The code I'm using is:
client = Mongo::MongoClient.from_uri(ENV['MONGOLAB_URI'])
db = client.db('test')
testcoll = db['testcoll']
testcoll.insert({:'_id' => "def", :'test' => "woop de doop"})
testcoll.find()
ENV['MONGOLAB_URI']=mongodb://heroku_app########:password#ds0xxxxx.mongolab.com:xxxxx/heroku_app########
I know that the uri is correct and contains the username and password, so why the error? Also, the error occurs on the insert() line, not the line where I authenticate.
Welp, turns out the url connects me to the heroku_app######## database, but I'm then trying to access the database called test so obviously I'm not authenticated. Would have been nice Mongo had returned an error specifying that I had logged in but not to the right database. Oh well.
I hadn't paid enough attention to the format of the uri, which is
mongodb://username:password#host:port/database
The database part is... pretty important, it turns out.
(I actually found the answer to this while writing the test, but if this answer had existed it might have saved me an embarrassingly large amount of time, so I'm writing it again and answering it myself.)

How do you Configure the Connection String for ODP.NET Connection String with FailOver?

Converting to ODB.NET from System.Data.OracleClient and need help converting my connection string. Here is what I use with System.Data.OracleClient.
SERVER=(DESCRIPTION_LIST=(LOAD_BALANCE=yes)(FAILOVER=ON)(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=172.26.140.80)(PORT=9960))(ADDRESS=(PROTOCOL=TCP)(HOST=172.26.140.81)(PORT=9960)))(CONNECT_DATA=(SERVICE_NAME=tactota))));uid=XXXXXXX;pwd=XXXXXXXX"
Here is what I have gotten to work with ODB.NET, but does not implement the other features of the above connection string.
Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=172.26.140.80)(PORT=9960)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=tactota)));User Id=XXXXXXXX;Password=XXXXXXXX;
Here is what I got when I tried to roll them together, but needless to say it did not work.
Data Source=(LOAD_BALANCE=yes)(FAILOVER=ON)(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=172.26.140.80)(PORT=9960))(ADDRESS=(PROTOCOL=TCP)(HOST=172.26.140.81)(PORT=9960)))(CONNECT_DATA=(SERVICE_NAME=tactota))); User Id=XXXXXX;Password=XXXXX;
Thanks!
Dave
Finally got it to work! Here is what I came up with
Data Source=(DESCRIPTION=(LOAD_BALANCE=yes)(FAILOVER=ON)(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=172.26.140.80)(PORT=9960))(ADDRESS=(PROTOCOL=TCP)(HOST=172.26.140.81)(PORT=9960)))(CONNECT_DATA=(SERVICE_NAME=tactota))); User Id=XXXXXXX;Password=XXXXXXXX;

Resources