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
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.
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.
I've been googling this for the last 3 hours, and I've had no luck. I'm trying to connect to a SQL Server 2008 with Java, which I normally access with SQL Management Studio. It's windows authenticated too, so it's not like I enter a username or password.
The two relevent lines of code:
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection conn = DriverManager.getConnection(db_connect_string, db_userid, db_password);
What I want to know is:
What am I supposed to put in for Class.forName? I just downloaded the latest JDBC. Yes I've looked around. Most sites tell me what it is, and why I need to set it, rather than what I need to set.
Where do I define a class path, and what do I define it as? I've googled this, and I can't find anything that tells me WHERE I set this.
Since it's a windows authenticated system, what do I use for db_connect_string, db_userid, and db_password? I'm assuming db_connect_string is localhost, right (if it's a local database)?
I'm not very well versed with any of this, so an explanation would be really appreciated!
The Microsoft JDBC driver supports Windows authentication for clients on Windows platforms. Beginning with the 4.0 release, we also offer pure Java Kerberos authentication regardless of platforms. You can find more details on Kerberos here - http://msdn.microsoft.com/en-us/library/gg558122.aspx and setting connection properties here - http://msdn.microsoft.com/en-us/library/ms378988.aspx
Our online help in general provides guidelines for building your connection url and making connections to SQL Server.
Actually, you can use JDBC (as well as jTDS) to connect to SQL Server from Java with Windows authentication. Please take a look here. Hope it helps!
I need to retrieve data from the database. I have the database name, username, password, servername, but I don't have the software installed in my machine. Can I connect to the db and retrieve the data from the db from database from Java code?
you need to have database drivers atleast like ODBC or JDBC drivers on your system where application runs to access the DB from other machine.
Yes. The jdbc driver .jar can be used stand alone. It logs a warning about a missing .dll, but that can be ignored unless you need to use windows auth.
From Java, it's easy as long as there is some kind of driver installed (for example, ODBC.) Try Googling connecting to db using odbc.
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.