"Data source name too long" exception

"Data source name too long" exception

Post by Stuart Leonar » Sat, 14 Jul 2001 21:31:09

The following program is throwing a "Data source name too long" exception. I
also tried "C:\\Invoice.xls", which did not work either. Any help on this
would be much appreciated. The source code , along with the error message,

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

public ConnecttoExcel() {


public void Connect() {

try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); } //loads the driver
catch (ClassNotFoundException e) {
System.out.println("Error: " + e);


try {
Connection db = DriverManager.getConnection("jdbc:odbc:Driver={Microsoft " +
"Excel Driver " +

DatabaseMetaData dma = db.getMetaData ();

System.out.println("\nConnected to " + dma.getURL());
System.out.println("Driver " + dma.getDriverName());
System.out.println("Version " + dma.getDriverVersion());


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
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:126)
at ConnecttoExcel.Connect(ConnecttoExcel.java:19)
at ConnecttoExcel.<init>(ConnecttoExcel.java:7)
at ConnecttoExcel.main(ConnecttoExcel.java:36)

"Data source name too long" exception

Post by dbian.. » Sat, 14 Jul 2001 22:30:47

> The following program is throwing a "Data source name too long" exception.
> Connection db = DriverManager.getConnection("jdbc:odbc:Driver={Microsoft " +
> "Excel Driver " +
> "(*.xls)};DBQ=c:/Invoice.xls;DriverID=22;READONLY=false","","")
> ;

The URL is supposed to refer to a DSN registered in the ODBC control
panel. Register the DSN and then refer to its name in the URL.



1. help - "data source name not found"

I have created a web application that uses ASP on the front end, which calls
VB functions that read and write to an Access database.

Everything works great when the VB DLL is in run mode, but after it is
compiled, I am getting the following message in the Event Viewer when trying
to connect to the Access database via ODBC:

"Data source name not found and no default driver specified from Microsoft
OLE DB Provider for ODBC drivers."

I have already created the ODBC data source (under System DSN).

Here is the relevant code from the DLL:

Dim Conn As ADODB.Connection

Set Conn = New ADODB.Connection
Conn.Open "webdb"  //////////this is where it is blowing up

Any suggestions?


2. Printscreen and Windows 95

3. "Bad data type" Exception

4. SOS: Cannot update a Remote View of an Access database, ODBC UPDATE error, Jet Engine Error 3503

5. Oracle Data Source - potential "security hole"

6. Is Visual Foxpro 5.0 slower than 2.6

7. "Error Configuring Data Source"

8. W4GL images - Component Versions

9. "Invalid data source" with DataReport

10. "Data source not found" message

11. Who can deal "LONG" data type

12. copying table data with "long" rows

13. "Data is too long for field"