Hi all,
I wrote the little standalone test class below. It tries to follow
SQuirreL's way to connect as close as I could do in such a little class.
Perhaps you could try out this class on a client where the problem exists.
Gerd
package pack;
import java.sql.Connection;
import java.sql.Driver;
import java.sql.SQLException;
import java.util.Properties;
public class SQuirreLConnectTest
{
public static void main(String[] args)
throws SQLException, IllegalAccessException,
InstantiationException, ClassNotFoundException
{
Connection connection = getConnection("org.postgresql.Driver",
"jdbc:postgresql://localhost/AnnaDB", "gerd", "", null);
System.out.println("Connected to: " +
connection.getMetaData().getURL());
}
/**
* @param props may be null
*/
public static Connection getConnection(String driver, String url,
String user, String pw, Properties props)
throws ClassNotFoundException, IllegalAccessException,
InstantiationException, SQLException
{
if (null == props)
{
props = new Properties();
}
props.put("user", user);
props.put("password", pw);
Driver driverInst = (Driver) Class.forName(driver).newInstance();
Connection jdbcConn = driverInst.connect(url, props);
if (jdbcConn == null)
{
throw new RuntimeException("Connect failed");
}
return jdbcConn;
}
}
Rob Manning wrote:
> Mark Neher wrote:
>
>>
>> I have been using Squirrel for almost two years at work to connect to
>> an Oracle 10g database. I recently installed it at home, as I
>> frequently have to provide support from there, and have been unable to
>> connect to the database -- I get the ubiquitous "The Network Adapter
>> could not establish the connection" message. I have a VPN connection,
>> and have had no other issues working with any other machines in our
>> network. I spoke to one of our DBAs; he tried it from his home, and
>> was able to connect, so there doesn't seem to be any inherent issue
>> with connecting from outside.
>>
>> Does anybody have any ideas ?? Any irregularities noticed relating to
>> VPN, firewalls, etc. ??
>
>
> Mark,
>
> It's funny you should be asking about this. A co-worker and I have had
> a similar experience.
> We both connect to the same Oracle 9i database from home using the same
> vpn software, and
> I never see the problem, but he consistently sees the problem. We both
> used the same Oracle 10g
> driver. Furthermore, he tried DBVisualizer (trial edition) and it
> connected fine. In SQuirreL I noticed in
> SQLDriverManager (line 125) it does java.sql.Driver.connect() instead of
> DriverManager.getConnection().
> I believe that part of the answer lies here. It's done this way (in
> SQuirreL) since it's possible to register multiple drivers
> that handle the same jdbc URL, and therefore it would be inappropriate
> to use DriverManager.getConnection.
> I suspect the other part may have to do with the Internet connection
> over which the vpn connection is
> made, although that's just a guess. It's baffling to me, but I'm still
> searching for an answer to this one. Not having the source code to the
> driver isn't really helping here :-(
>
> Rob Manning
>
>
> CollabraSpace - Revolutionary Collaboration
> Visit us at http://www.collabraspace.com
> This message has been scanned for viruses by
> ClamAV v0.83
>
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by:
> Power Architecture Resource Center: Free content, downloads, discussions,
> and more. http://solutions.newsforge.com/ibmarch.tmpl
> _______________________________________________
> Squirrel-sql-users mailing list
> Squ...@li...
> https://lists.sourceforge.net/lists/listinfo/squirrel-sql-users
>
|