Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

DSN less connections (this is driving me crazy!!)

2 views
Skip to first unread message

Stuart Leonard

unread,
Jul 15, 2001, 9:57:20 PM7/15/01
to
I hope someone can provide an answer to this problem. I am receiving the
following SQL Exception "Data source name too long".

I am using JDK 1.1.8, Windows 98 OS, btw

I also downloaded Microsoft MDAC 2.6, available at
http://www.microsoft.com/data/download_260rtm.htm
thinking that the ODBC driver just may be out of date.

The source code follows:

import java.sql.*;
import java.lang.*;
import java.util.Enumeration;
import java.util.Properties;
public class ConnecttoExcel {

public ConnecttoExcel() {
Connect ();

}

public void Connect() {

try {
Connection db= null;
Statement st = null;
String fullConnectionString = "jdbc:odbc:Driver={Microsoft Access
Driver(*.mdb)};DBQ=C:\\requisition.mdb";

try {
Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver"); }
catch (ClassNotFoundException r) {r.printStackTrace();}
db = DriverManager.getConnection (fullConnectionString);
st = db.createStatement ();

DatabaseMetaData dma = db.getMetaData ();

System.out.println("\nConnected to " + dma.getURL());
System.out.println("Driver " + dma.getDriverName());
System.out.println("Version " + dma.getDriverVersion());
System.out.println("");
}
catch (SQLException e ) {e.printStackTrace();}

}
public static void main (String[] args) {

ConnecttoExcel conn = new ConnecttoExcel();
}
}

java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name too
long
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:3661)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:3814)
at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(JdbcOdbc.java:1029)
at
sun.jdbc.odbc.JdbcOdbcConnection.initialize(JdbcOdbcConnection.java:145)
at sun.jdbc.odbc.JdbcOdbcDriver.connect(JdbcOdbcDriver.java:165)
at java.sql.DriverManager.getConnection(DriverManager.java:83)
at java.sql.DriverManager.getConnection(DriverManager.java:141)
at ConnecttoExcel.Connect(ConnecttoExcel.java:22)
at ConnecttoExcel.<init>(ConnecttoExcel.java:8)
at ConnecttoExcel.main(ConnecttoExcel.java:37)

N...@utel.no

unread,
Jul 16, 2001, 6:09:40 PM7/16/01
to
Stuart Leonard wrote:

> I hope someone can provide an answer to this problem. I am receiving the
> following SQL Exception "Data source name too long".
>
> I am using JDK 1.1.8, Windows 98 OS, btw

The JDBC-ODBC driver doenst support DNS less connection, your
datasource must be defined in the system (use the datasource administartion
tool), and use that name to connect.

--
Nils O. Selåsdal

Geeta Kottapalli

unread,
Jul 17, 2001, 12:09:52 PM7/17/01
to

Even I am getting the same error from yesterday !!
Did you figure it out a way for DNS-less connection.

Please help me.

Thanks,
Geeta

Emir Alikadic (ADNOC IS&T)

unread,
Jul 22, 2001, 6:06:10 AM7/22/01
to
Your URL is wrong: you omitted a ";" before specifying the DSN
properties. The correct URL syntax is:

jdbc:odbc:[;name=value]*

e.g.

jdbc:odbc:;DRIVER={Microsoft Access
Driver(*.mdb)};DBQ=C:\\requisition.mdb

To use DSN-less connections you must use JDK 1.3 or higher.
AFAIK if you're using DSN-less connection, you can only connect to a
local database; to connect to a remote database, you'll have to use
RMIJDBC (http://www.objectweb.org/RmiJdbc/RmiJdbcHomePage.htm). Then
again, why would you want to connect to MS Access remotely in the first
place, when it doesn't support simultaneous connections?

Cheerioh!

Emir.

0 new messages