ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Antoine Levy-Lambert <>
Subject AW: SQL task and Microsoft SQL Server 2000
Date Tue, 25 Nov 2003 21:03:42 GMT
Hi Robert,

this is the relevant bit of source code in ant (, CVS HEAD):

            log("connecting to " + getUrl(), Project.MSG_VERBOSE);
            Properties info = new Properties();
            info.put("user", getUserId());
            info.put("password", getPassword());
            Connection conn = getDriver().connect(getUrl(), info);

            if (conn == null) {
                // Driver doesn't understand the URL
                throw new SQLException("No suitable Driver for " + url);
it is true that it is not possible with the current ant (including
ant1.6beta2) to add specific connection properties.

I have done a Lycos search for SQL Server JDBC drivers, and I have found
this one :
Class.forName( "net.sourceforge.jtds.jdbc.Driver" );
cn = DriverManager.getConnection(
"jdbc:jtds:sqlserver://MyDbComputerNameOrIP:1433/master", sUsr, sPwd );

this example implies that if you can use the driver mentioned above, you can
include the database name in the URL.

the doc of the Opta2000 driver gives this syntax :

If you cannot include the database name in the URL with your current driver,
a workaround is to make the database you want to connect to the default
database of the user doing the connection.

Hopes this helps,


-----Ursprungliche Nachricht-----
Von: Robert Rice []
Gesendet: Dienstag, 25. November 2003 17:24
Betreff: SQL task and Microsoft SQL Server 2000

I'm trying to utilize the SQL task to connect to Microsoft SQL Server
2000.  Anybody been able to do this?

The task takes on the form of:

Where you are required to specify driver, url, userid and password.  In my
case, I need to also specify the databaseName.  I've tried to create a url
that contains the databaseName, but have thus far been unsuccessful.

I'm guessing that the sql task uses the following DriverManager method
signature to create a database connection.
public static Connection getConnection(String url,
                                       String user,
                                       String password)
                                throws SQLException

I've been useing an alternate form programmatically, to successfully
connect to SQL Server 2000.
public static Connection getConnection(String url,
                                       Properties info)
                                throws SQLException

In this case, I build a Properties object with user, password and

Possibly the sql task could be extended to accept a variable length list
of db specific parameters, used to construct a Properties object.  This
would be useful in any case.

But for now, maybe there is a simpler way that I am overlooking.

Robert Rice

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message