I'm writing a Java program that retrieves data from an MS Access database. My code is as follows:
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=" + databaseLocation + databaseName +";selectMethod=cursor; READONLY=true; TYPE=FASTLOAD";
con = DriverManager.getConnection(url);
I am using a basic JDBC:ODBC bridge. It seems a Type 4 driver would be better. However I'm writing the program to be used on a different PC and I would rather they do not have to install any drivers for it to work. I don't remember installing anything on my PC.
Can anyone tell me will this work with any copy of Windows? That is are the JDBC drivers I'm using installed with Windows or Java or Access by default?
No, there are no type IV JDBC drivers installed on Windows.
I'm not aware of a free type IV JDBC driver for Access.
The JDBC-ODBC bridge is available for 32-bit JVMs, but not for 64-bit. (A DLL is required that isn't part of the 64-bit JDK.)
duffymo is correct as far as I know when he / she says "there are no type IV JDBC drivers installed on Windows"
hxtt.com/access.html is not a JDBC type 4 driver it uses Samba and not a Native Protocol which is what is required for a JDBC type 4 driver.
What you need is a JDBC type 3 driver which uses its own Network protocol to communicate between the client which in your case would be the remote PC and a server component. Commercially available is the Easysoft JDBC-ODBC Bridge offers such a solution. You install the software on the machine containing the MS Access database or a machine that can use a UNC path to the access database and then you distribute the EJOB.jar file to the machines that require access to that database along with your Java application. You can use Easysoft from both 32-bit and 64-bit Java applcations.
Many powerful SQL syntax (for instance, select ... into outfile) at http://www.hxtt.com/access/sqlsyntax.html or SQL functions (for instance, GROUP_CONCAT) at http://www.hxtt.com/access/function.html are NOT supported by MS ACCESS engine at all. With HXTT Access' help, you can access local mdb/accdb file of UNIX/LINUX/MAC OS easily without any third-party component.
HXTT is AFAIK incorrect in their statement about there JDBC is type 4.
All drivers of HXTT drivers are type 4.
it uses SMB and not a Native Protocol
Wrong. It can run for embeded mode, client/server mode, in-memory mode, mapped driver, SMB protocol, http protocol, https protocol, and mobile OS.
If you choose to download and evaluate it, you will find the following information at http://www.hxtt.com/access.html ISN'T a lie:
HXTT Access contains the only type 4 JDBC(1.2, 2.0, 3.0, 4.0, 4.1) driver packages for Microsoft Access version from 95, 97, 2000, XP, 2002, 2003, 2007, to 2010, which supports transaction, embedded access, remote access, client/server mode, memory-only database, compressed database(.ZIP, .JAR, .GZ, .TAR, .BZ2, .TGZ, .TAR.GZ, .TAR.BZ2), SMB database(smb), url database(http, https, ftp), and java.io.InputStream database. Through the embedded Pure Java database engine, MS Access database can be deployed and acessed on any platform with JVM. With JDBC1.2, JDBC2.0, JDBC3.0, JDBC4.0, JDBC4.1, and SQL92 support, programmers needn't special coding, and DBA can use any Java database tool to access easily local data or remote data.
Related
I want to connect oracle database without oracle client.After searching that how can i do this, figure out I must be use oracle instance client . But how can I use this? Icant find something about that.
The recommended (and most frequently used) JDBC driver for Oracle is the "thin driver". It doesn't need anything installed on the client (and is free).
This FAQ might be useful : http://www.orafaq.com/wiki/JDBC
Oracle client is a software that can easily be found and downloaded from oracle.com website. It has different versions for Windows, Linux, etc. After installing appropriate client, you will be able to communicate with the database by specifying its parameters such as host address, username, password etc. Without it, I think it's not possible to communicate with the database server.
http://www.orafaq.com/wiki/JDBC
On this page it says: "You must use a JDBC OCI driver appropriate to your Oracle client installation." What I understand from here is that you should use JDBC driver in your application, but without client installed, it will be nonsense.
Currently I've developed a small desktop application as an enhancement to my project, which reads '.mdb' file and connects as an MS-Access database using 'JDBC-ODBC Driver'.
This is works fine in Windows environment, but I am unable to run the same on Debian-Linux machine.
The code is below:
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
oAccessConnection = DriverManager.getConnection("jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ="+mdbFileName);
}
catch (Exception oException)
{
logger.info("Exception",oException);
}
How can I diagnose the problem?
JDBC-ODBC bridge won't work in Linux machine, so you have to use other JDBC driver, which will have access to MS-ACCESS directly (not thru ODBC bridge) - try to look in this thread
Unless you can find MS Access for Linux, I don't believe this will work. MS Access needs to run on a supported operating system.
You can run MS Access on a seperate Windows box and access it remotely, or you can install Windows in a virtual machine on the same box e.g. https://www.virtualbox.org/
Or you can use a database which can be used on other OSes. (This is almost any database accept MS Access and MS Sql Server)
If you just need to manipulate the file data and don't need to run complex queries, then you could use jackcess to work with the access file (it works on any platform with no extra libraries). the only downside is that it doesn't support jdbc or have a way of executing sql queries.
I want to access connection on java. But i cant, because it is there odbc problem. Iam useing Windows7 x64. It's not installed odbc driver on windows 7. And is there just System DSN on Odbc Data Source Administator. I want to add but no odbc driver, only sql server.
What can i do?
If you are working on 64 bit version of Windows then you can use 64 bit and 32 bit environment. Such environment consist of Java (JDK or JRE) and database drivers. For Java applications the best way of accessing database is via JDBC driver. Then you need not to worry about 32 or 64 bit environment, you only put .jar file or files in directory that is part of CLASSPATH environment variable.
In case of MS Access you can use JDBC-ODBC bridge that is present by default in Sun (now Oracle) implementations of JRE. But before that you must configure ODBC connection with MS-Access database. This can be done via ODBC Manager or via connect string.
I think connect string is easier, because it looks like:
jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=c:\\Nwind.mdb
all you have to do is to point at your .mdb file. This should work with 32 and 64 bit versions of JRE.
If you want to configure database access in ODBC then do it for both 32 and 64 bit environments using:
c:\windows\syswow64\odbcad32.exe (32 bit)
c:\windows\system32\odbcad32.exe (64 bit)
Then in connect string you can use DSN name you have just created like:
jdbc:odbc:DSN_NAME
You should consider JDBC-ODBC bridge, for example from OpenLink.
The usual way to access a Db with Java is with a JDBC driver. Most databases have JDBC drivers. Click here for the JDBC tutorial
My Java application uses a .mdb database and i want to run this application on MAC OS for that am definitely gonna nead a TYPE 4 JDBC driver i have google and came across two
- HXTT & StelsMDB but both are out of my reach
So if any body has some alternative or suggestions please reply.
Thanks in advance
I've used jackcess to read the tables from an MDB and convert the database to sqlite3. Not ideal if you need to keep the .mdb format, but it allowed me to keep the database in a single file and made the database cross-platform.
MS Access databases on MS Windows are driven by the Microsoft Jet Engine. Different from client server database management systems like MS SQL Server or MySQL the connection to a MS Access database runs in embedded mode via OLE and some DLLs.
As far as I know there is no Jet Engine implementation for operating systems other than MS Windows. So if you want to connect to a MDB file on Mac OS a simple JDBC driver is not enough. There has to be some kind of emulation layer to emulate the Jet Engine DLLs. According to the HXTT website this is exactly the way the HXTT JDBC driver works.
From the HXTT website:
It contains a fast database engine
written in Java, which supports
embedded and server modes.
If the usage of the MS Access database format is an absolute requirement, then these kind of emulation might be the best way for you. But you have to testify if the compatibility level is high enough. (Maybe there is no way to access VBA macros contained in the MDB file.)
It seems there is no open source project doing the same kind of emulation like HXTT.
There are several alternatives. If you want an embedded database system then you can use for example
SQLite (this JDBC driver supports Mac Os) (one database file, requires some native libraries),
H2 (only a few database files, pure Java) or
Apache Derby (many database files, pure Java).
Or you can use a client server database management system, install the server on a host and connect to that host from your Mac OS machine. For that you can use for example
PostgreSQL
Firebird
MySQL
Even the pure Java databases H2 and Derby have client server modes.
I suppose UCanAccess is what you are looking for.
It is an open source Java JDBC Driver implementation which allows Java developers and jdbc client programs (e.g., DBeaver, NetBeans, SQLeo, Open Office Base, Libre Office Base, Squirrell) to read/write Microsoft Access database. Because it is a pure java implementation it run in both Windows and non-Windows Operative Systems (e.g., linux/unix). No ODBC needed.
StelsMDB is not as expensive as HXTT, still not open source...
http://www.csv-jdbc.com/stels_mdb_jdbc.htm
Have'n tried it, but evaluation copy is available.
Anyone else got suggestions? I'm looking for an opensource variant myself. Shouldn't be impossible to build on top of jaccess ...
We use stelsMDB JDBC driver at our server to read/write MDB files. It is platform-independent, so you can use it in MacOS as well.
Oracle has this concept of allowing database users to be identified by the operating system user who is running the program that is connecting to Oracle. See here.
This allows you to do, as that user on a unix machine for example, a command such as:
sqlplus /
I am attempting to write a Java program for Oracle 10.2 which connects without a username or password. The obvious choice of url:
jdbc:oracle:thin:/#localhost:1521:MYDBSID
doesn't work, giving an error (Sorry I don't have the error available right now).
I have attempted many other forms of doing this as well, but with no luck.
Does anyone have any suggestions on how I can connect a Java program to Oracle using the OS identification method?
The JDBC Thin driver is a 100% pure Java implementation that cannot collect the needed information from the operating system.
The JDBC OCI driver can do this! Use jdbc:oracle:oci8:/#MYDBSID, it will require that the Oracle driver be installed on that machine, not a problem if this is a server (and is faster to boot and supports many more features than the thin driver)
The jdbc driver that oracle ships does NOT have the capability of gathering the OS username and password from the URL that you provide it. Suppose, there are 3rd party JDBC driver providers for ORACLE, one of them might provide the functionality that you're asking for. you should google around.
Thanks to those that answered. We've gone with the OCI driver.
I did find documentation to suggest that Oracle 11g does support OS user authentication via the thin driver though:
http://www.orindasoft.com/public/Oracle_JDBC_JavaDoc/javadoc1110/oracle/jdbc/OracleConnection.html#CONNECTION_PROPERTY_THIN_VSESSION_OSUSER
I don't have an 11g setup to test this on, so I can't be certain this works.
OS authentication support in the JDBC thin driver was added in 11g (you can download the JDBC thin driver from 11.2.0.4 on OTN).
Note that you have to allow remote OS authentication on the server (over TCP) otherwise it will only work with sqlplus using IPC or BEQ locally. In your init.ora file, add this:
REMOTE_OS_AUTHENT = TRUE
Then if you user is "osuserdemo" on the client machine, create a database user like this and restart the DB:
CREATE USER OSUSERDEMO IDENTIFIED EXTERNALLY;
GRANT CONNECT,CREATE SESSION,RESOURCE TO OSUSERDEMO;
And the JDBC thin driver should be able to connect without any username or password.
It's worth noting that this feature - considered as highly unsecured - has been de-supported in 12c.
If you're accessing Oracle from a J2EE appserver, you could achieve a similar end by using JNDI to acquire a datasource.
The 11g thin driver can connect using Kerberos authentication.
See Connect to an Oracle database using Kerberos
try following
jdbc:oracle:thin:username/password#localhost:1521:MYDBSID
you need to specify the account information
sqlplus / as sysdba on a unix machine which go through the operation system autentication
jdbc:oracle:oci:# works with ojdbc6.jar and Oracle 11g2