Using UCanAccess to read mdb file from MATLAB - matlab

I am using the MATLAB Database toolbox to read data from MS Access *.mdb files. In the past I did this using the jdbc:odbc bridge 'sun.jdbc.odbc.JdbcOdbcDriver.' However, this driver is no longer supported or available, and I am implementing a solution using the UCanAccess driver. This is based on the solution described in the MATLAB Answers forum here. However, I am encountering a driver error and am hoping someone can help offer some suggestions!
Here is the MATLAB documentation on the database() function.
I've downloaded and installed UCanAccess 5.0.0.
Below is my MATLAB code:
javaaddpath('C:\Program Files\MATLAB\UCanAccess\UCanAccess-5.0.0-bin\ucanaccess-5.0.0.jar');
javaaddpath('C:\Program Files\MATLAB\UCanAccess\UCanAccess-5.0.0-bin\lib\commons-lang3-3.8.1.jar');
javaaddpath('C:\Program Files\MATLAB\UCanAccess\UCanAccess-5.0.0-bin\lib\commons-logging-1.2.jar');
javaaddpath('C:\Program Files\MATLAB\UCanAccess\UCanAccess-5.0.0-bin\lib\hsqldb-2.5.0.jar');
javaaddpath('C:\Program Files\MATLAB\UCanAccess\UCanAccess-5.0.0-bin\lib\jackcess-3.0.1.jar');
javaaddpath('C:\Program Files\MATLAB\UCanAccess\UCanAccess-5.0.0-bin\loader\ucanload.jar');
db_path = 'C:/Data/file.mdb';
url = ['jdbc:ucanaccess://' db_path];
conn = database('','','','net.ucanaccess.jdbc.UcanaccessDriver',url);
The connection object is created in MATLAB, but a Warning pops up:
WARNING:You shouldn't use 'user' reserved word as column name in the table BatchHistory_Table (it refers to the database user).
Escape it in your SQL!
(e.g. SELECT [USER] FROM TABLE WHERE [USER]='Joe')
Does this imply something is incorrect or corrupt with my mdb file itself? The mdb files are created by a 3rd party software package, and I can't alter any of the data, column names, or table names. I just want to read the data from the mdb file.
Then when I look at the connection Message, conn.Message, this is:
'JDBC Driver Error: UCAExc:::5.0.0-SNAPSHOT unexpected token: AND required: VALUE'
I don't know what steps to take next or how to find more information on this Driver Error. Does this have to do with an expected query? I haven't tried querying yet - I first want to open the connection and then make my queries on the mdb file.
Thank you in advance for your help!

Related

Where can I find a complete list about replication slot options in PostgreSQL?

I an working on PG logical replication by Java, and find a demo on the jdbc driver docs
PGReplicationStream stream =
replConnection.getReplicationAPI()
.replicationStream()
.logical()
.withSlotName("demo_logical_slot")
.withSlotOption("include-xids", false)
.withSlotOption("skip-empty-xacts", true)
.start();
then I can parse message from the stream.
This is enough for some daily needs, but now I want to know the transaction commit time.
From the help of the question on stackoverflow, I add .withSlotOption("include-timestamp", "on") and it is working.
My question is where can find a complete list about the "slot option", so we can find them very conveniently instead of search on google or stackoverflow.
The available options depend on the logical decoding plugin of the replication slot, which is specified when the replication slot is created.
The example must be using the test_decoding plugin, which is included with PostgreSQL as a contrib module for testing and playing.
The available options for that plugin are not documented, but can be found in the source code:
include-xids: include the transaction number in BEGIN and COMMIT output
include-timestamp: include timestamp information with COMMIT output
force-binary: specifies that the output mode is binary
skip-empty-xacts: don't output anything for transactions that didn't modify the database
only-local: output only data whose replication origin is not set
include-rewrites: include information from table rewrites caused by DDL statements

ERROR: cannot execute CREATE TABLE in a read-only transaction - Jasper reporting

I'm facing this annoying problem in Jasper. I have created a report based on a PostgreSQL function. When I watch the preview, I do not have any problem with the results. However, when I publish the report and try to execute it, I get this error:
org.postgresql.util.PSQLException: ERROR: cannot execute CREATE TABLE in a read-only transaction
I've checked on the internet for a possible solution, so far this is the only thing that I have found with a similar problem:
https://community.jaspersoft.com/questions/814793/report-execution-fails-due-read-only-transaction-mode
However, adding the property to the URL does not work, or I'm not so sure if I have to write it in this way:
jdbc:postgresql://server:5432/data_base?defaultReadOnly="false"
In Jasper, what else can I do? I only can query the function, and requiring any change in it is an HUGE bureaucratic issue.
Jasper Studio 6.3.0
According to the documentation the JDBC connection parameter would be readOnly=false.
Have you verified that you are not connecting to a streaming replication standby server?

Can I use JSON_EXTRACT in a Domo SQL DataFlow

Domo calls one of the DataFlow types a "MySQL DataFlow". MySQL has a function called JSON_EXTRACT. How can I use this on a field that contains some JSON encoded data? I receive back the error:
The database reported a syntax error. FUNCTION json_extract does not exist
I know this is a somewhat old question, but I think the answer is that Domo uses an older version of MySQL (5.6) that does not support the JSON_EXTRACT function (5.7 and later).
You can check the version by running this statement in a MySQL DataFlow transformation step:
SELECT VERSION();
When I run that on the Domo instance I use at work I see 5.6.28-76.1-56
If you go to the JSON Functions page of the MySQL documentation and try to select any version before 5.7 from the dropdown in the upper right of the page you will see a message saying "The page you are viewing does not exist in version X.X"

Oracle Data Integrator 11g Reverse Engineer not importing tables

I am New To ODI 11g, i have to transport data from one Database(Oracle) to another Database(Oracle), for this the table in source was already imported in the source model, i am trying to setup Target database's meta data in ODI 11g and i have done all the steps right when i try to reverse engineer this new model which i created nothing happens. I am stuck with this problem at work since there is no error so i cannot think of any reason why meta data is not being imported
I would like to clarify this, the target table which i am trying to import is accessed from ODI with the super user
Any help would be appreciated.
Could you check that the schema used to connect to the Dataserver where the target table is located actually got the privileges to access the target table?
If not, grant select and insert (and maybe update, delete depending on the IKM you use) on that table.
I faced the same issue and resolved it by providing read access to the schema ODI is using to reverse engineer.
As I was using standalone installation, ODI studio log had the below information:
[2015-01-17T19:10:21.979+05:30] [] [NOTIFICATION] [] [] [tid: 2374]
[ecid: 0000Kfs7s20Fg4WFLzvH8A1KiWkx00000d,0] New data source:
[HR/*******#jdbc:oracle:thin:#//localhost:1521/pdb1]
HR schema was the first schema I reverse engineered, and it was being used as default user to read other schemas.
Try checking the agent logs to see what user is being used and provide it the privileges on all other schema's.
Althoug I dont know how to tell ODI to use a particular user to access database while reverse engineering. It would be great if some one gives some insight on it.
Probably on masking of reverse engineering you are missing character: %

How can I get my client application name to show up on zos from java?

This page says I can put "clientProgramName" as one of the connection parameters and it will show up on db2 as the correlation ID.
And I quote:
In a java.util.Properties value in the info parameter of a
DriverManager.getConnection call.
We're using z/OS. The z/OS version of DB2 seems a lot more limited in terms of this kind of stuff.
Setting the client program name in the params hash of the connect call seems to have no effect, and when I put it on the end of the connect string url like this (which it also says I can do):
jdbc:db2://localhost:5036/DBNAME:clientProgramName=myprog
I get this error:
[jcc][10165][10051][4.11.77] Invalid database URL syntax:
jdbc:db2://localhost:5036/DBNAME:clientProgramName=myprog.
ERRORCODE=-4461, SQLSTATE=42815
Is there any way to send a custom user string to a z/OS db2 server so that connection can be identified on the server?
Depending on the method you use to connect to DB2, you use:
Class.forName
Class.forName("com.ibm.db2.jcc.DB2Driver");
Properties props = new Properties();
props.put("user", "scott");
props.put("password", "tiger");
props.put("clientProgramName", "My Program 1");
Connection conn = DriverManager.getConnection(
"jdbc:db2://localhost:50000/sample", props);
DataSource
Connection conn = null;
DB2SimpleDataSource ds = new com.ibm.db2.jcc.DB2SimpleDataSource();
ds.setDriverType(4);
ds.setServerName("localhost");
ds.setPortNumber(50000);
ds.setDatabaseName("sample");
ds.setUser("scott");
ds.setPassword("tiger");
ds.setClientProgramName("My Application 2");
conn = ds.getConnection();
I wrote a blog about that: http://angocadb2.blogspot.fr/2012/12/nombre-de-la-conexion-java-en-db2-java.html (Use your favorite translator because it is in Spanish)
According to this page on Info Center, there should be a function on the DB2Connection interface that allows you to change your application identifier, setDB2ClientApplicationInformation (I can't link directly, because there is no anchor, just search for that name).
You can pull the current application ID using the CURRENT CLIENT_APPLNAME special register:
SELECT CURRENT CLIENT_APPLNAME FROM SYSIBM.SYSDUMMY1
There are some other ways to set that register listed on the Info Center link listed above, including the WLM_SET_CLIENT_INFO function.
I am no DB2 expert, but I am looking at a trace record, generated by DB2 for z/OS, that contains a "correlation ID" (field QWHCCV in the product section correlation header of the trace record) that matches the value I set using setClientProgramName (method of the DB2 data source in my Java application).
My Java application is similar to the "DataSource" example given by AngocA, which is similar to the code quoted in the IBM technote 'The name of a DB2 JDBC application appears as "db2jcc_application". How to change it?'. This Java application, running on my Windows PC, connects to DB2 for z/OS. It also - and this is important, depending on which DB2 traces you have started (discussed below) - actually does something after connecting. For example:
pstmt=conn.prepareStatement("SELECT ... ");
rset=pstmt.executeQuery();
When you say, regarding the first example given by AngocA, "it doesn't do anything": what did you hope to see? Exactly where are you looking, what are you looking for, and what method (or tool) are you using to look for it?
For example, if you are looking for SMF type 100, 101, or 102 records (generated by DB2 traces) containing QWHCCV field values that match your correlation ID, then (with apologies if this is the bleeding obvious, teaching you how to suck eggs), on DB2 for z/OS, you need to start the DB2 traces (using the DB2 command START TRACE) that generate those records. Otherwise, there will be nothing to see ("it doesn't do anything"). Note that not all DB2 trace records generated by an application (such as the Java application described above) will contain your correlation ID; prior to a certain point in processing, the correlation ID of such records will have a different value (but that is getting off-topic, and anyway is about as far as I am comfortable describing).
Warning: Experiment with starting DB2 traces on a "sandbox" (development or test) DB2 system, not a production DB2 system. DB2 traces can result in large volumes of data.
You will also see the correlation ID in the message text of some DB2 V10 messages (such as DSNL027I) after "THREAD-INFO=".
For me I had to add a semicolon after each connection parameter.
EX for your case:
jdbc:db2://localhost:5036/DBNAME:clientProgramName=myprog;
EX with multiple params:
jdbc:db2://localhost:5036/DBNAME:clientProgramName=myprog;enableSysplexWLB=true;blah=true;