Connect to a SQL Anywhere 5.0 DB from java - java

I need to connect to a Billing system which is backed by a SQL Anywhere 5.0 DB and I am pretty much drawing a blank when I try to find a jodbc driver for this.
I was successful in doing this with an upgraded version(SQL Anywhere 11) by using the iAnywhere jodbc drivers that I found in the DB installation folder.
DriverManager.registerDriver((Driver) Class.forName("ianywhere.ml.jdbcodbc.jdbc3.IDriver").newInstance());
con = DriverManager.getConnection(String.format("jdbc:ianywhere:dsn=%s;uid=%s;pwd=%s;", dbDsn, dbUser, dbPassword));
But, the 5.0 version does not have any JDBC-ODBC drivers.
Also, I need to connect via the odbc way as the DSN is created and managed by the Billing software.
Any help with this would be greatly appreciated.

If I understand you correctly, you need to connect from your unnamed Java app to the target SQL Anywhere 5.0 DB, through the ODBC DSN maintained by the Billing software. That means you need a JDBC Driver for ODBC Data Sources, such as the one from my employer. The free two-week trial should be enough for your to figure out whether this will do the job for you.

Related

How can my Java program that uses Oracle Database work on other PCs?

I am new to Oracle Database and database management systems in general. At the moment I am developing a Java program that needs to use Oracle Database (contest requirement) but I am wondering, is my program only going to work on my local machine?
I used SQLite before, but that is a server-less database management system and it only connects to a file. Instead, JDBC connects to an URL like this:
Connection connection = null;
connection = DriverManager.getConnection("jdbc:oracle:thin:#localhost:1521:mkyong","username","password");
So, from what I understand, if I send my program to a friend for example, in order for my program to work, Oracle Database must be already installed and configued on his PC.
With SQLite, I only needed to include a *.sqlite file with the program that the program used.
Am I missing something here? Thanks!
If your Oracle database is accessible by your friend's computer because
- it is on the same network
- there is a VPN involved
- your database is on the internet
then your friend's computer needs an Oracle JDBC driver (a small jar) but not its own installation of the Oracle DBMS.
Otherwise an installation of Oracle is required. Consider Oracle Database XE that according to the website "Oracle Database 11g Express Edition is an entry-level, small-footprint database based on the Oracle Database 11g Release 2 code base. It's free to develop, deploy, and distribute; fast to download; and simple to administer." There are Windows 64, Windows 32 and Linux 64 downloads available.

How can I connect oracle database without oracle client?

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.

How do I get started using JDBC and SQL Server 2008 R2?

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!

Can we connect to SQL Server 2005 database from code with out having the installation of client and server

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.

Connection to Oracle without a username or password

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

Categories