How Do I Access Connection With Java? - java

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

Related

Oracle JDBC thin client 64 bit

I'd like to know if there is a specific driver for 64-bit systems. I have a 64-bit tomcat server and I need to install the oracle driver. I did not see anything specific in the Oracle download page.
Instant Client Downloads for Microsoft Windows (x64)
http://www.oracle.com/technetwork/topics/winx64soft-089540.html
Does this help?

Are any JDBC drivers installed as default with Windows?

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.

java.sql.SQLException: [Microsoft][ODBC Driver Manager] The specified DSN contains an architecture mismatch between the Driver and Application

As I have installed MS office 2007 on Windows 7 64 bit and I also installed jdk 32 and 64 bit but when I try to connect to MS Access ans I already created system DSN the above exception throws by the code
There's no ODBC bridge driver DLL in the Java 64 bit code base, so perhaps that's the problem. You'll either have to buy a JDBC driver that can connect to Access or switch databases. Derby comes bundled with JDK 6 and higher. Perhaps that will serve your needs.
Java code is not bit specific and as "duffymo" says there is no ODBC bridge in Java. The ODBC bridge you are using is calling the MS ODBC driver manager with the same bit size as the ODBC bridge. The error is comming back because the ODBC driver the driver manager is trying to open is of a different size.
To resolve this you simply need to make sure the the ODBC Bridge is of the same bit size as the MS Access ODBC driver is on your machine.

Type 4 JDBC driver for MS ACCESS(.mdb) database?

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.

Connection problem in Win2k3 server 64 bit with JDBC

DriverManager#getConnection() returns null when I am deploying my JSP/Servlet package in a Windows 2003 Server environment (64 bit). The database is Microsoft SQL 2005 Enterprise Edition.
The code is:
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc:odbc:calsoft2k","xxx","xxx");
The same code is working without any problems in Windows XP (32 bit) box. I am using Apache Tomcat 6.X server in both production and development environment.
Any pointers?
Use a real JDBC driver instead of the (pardon me) lousy ODBC bridge driver.
Decent DB vendors supplies their own JDBC drivers. The one for SQL2005 can just be found at microsoft.com. This driver is however known not to be very optimal in both the performance and the level of JDBC API support. You could also consider the much faster and better jTDS driver instead.

Categories