Showing posts with label applet. Show all posts
Showing posts with label applet. Show all posts

Thursday, March 8, 2012

Connecting to a SQL Server 2005 over SSH using PuTTY

I'm having a problem connecting to my remote db from Management Studio, but I
am able to create an ODBC connection from the Data Sources applet in the
Control Panel.
PuTTY is setup to convert localhost:21433 to 192.168.100.242:1433 (the
address of my remote db server).
When I specify localhost:21433, provide the username, password, and catalog
to the Data Sources applet it connects fine. I then can use that DSN in
Visual Studio 2005 as a connection to the db.
However, when I try localhost,21433 in Management Studio, it gives me the
default connection error which talks about not having remote access enabled.
Please give me a hand with this as it is very important that I be able to
use the Management Studio tools for my app development.
Thanks in advance.
Trevor Murphy wrote:
> I'm having a problem connecting to my remote db from Management Studio, but I
> am able to create an ODBC connection from the Data Sources applet in the
> Control Panel.
> PuTTY is setup to convert localhost:21433 to 192.168.100.242:1433 (the
> address of my remote db server).
> When I specify localhost:21433, provide the username, password, and catalog
> to the Data Sources applet it connects fine. I then can use that DSN in
> Visual Studio 2005 as a connection to the db.
> However, when I try localhost,21433 in Management Studio, it gives me the
> default connection error which talks about not having remote access enabled.
> Please give me a hand with this as it is very important that I be able to
> use the Management Studio tools for my app development.
> Thanks in advance.
Does the connection error mention Named Pipes? If so, in the connection
dialog, click on Options, and under Connection Properties, make sure the
protocol explicitly states "TCP/IP".
Tracy McKibben
MCDBA
http://www.realsqlguy.com
|||I had gone to options>>connection properties and I set he network protocol to
tcp/ip. I couldn't set the connect to database b/c it wasn't connecting with
the server.
Anything else?
"Tracy McKibben" wrote:

> Trevor Murphy wrote:
> Does the connection error mention Named Pipes? If so, in the connection
> dialog, click on Options, and under Connection Properties, make sure the
> protocol explicitly states "TCP/IP".
>
> --
> Tracy McKibben
> MCDBA
> http://www.realsqlguy.com
>

Connecting to a SQL Server 2005 over SSH using PuTTY

I'm having a problem connecting to my remote db from Management Studio, but
I
am able to create an ODBC connection from the Data Sources applet in the
Control Panel.
PuTTY is setup to convert localhost:21433 to 192.168.100.242:1433 (the
address of my remote db server).
When I specify localhost:21433, provide the username, password, and catalog
to the Data Sources applet it connects fine. I then can use that DSN in
Visual Studio 2005 as a connection to the db.
However, when I try localhost,21433 in Management Studio, it gives me the
default connection error which talks about not having remote access enabled.
Please give me a hand with this as it is very important that I be able to
use the Management Studio tools for my app development.
Thanks in advance.Trevor Murphy wrote:
> I'm having a problem connecting to my remote db from Management Studio, bu
t I
> am able to create an ODBC connection from the Data Sources applet in the
> Control Panel.
> PuTTY is setup to convert localhost:21433 to 192.168.100.242:1433 (the
> address of my remote db server).
> When I specify localhost:21433, provide the username, password, and catalo
g
> to the Data Sources applet it connects fine. I then can use that DSN in
> Visual Studio 2005 as a connection to the db.
> However, when I try localhost,21433 in Management Studio, it gives me the
> default connection error which talks about not having remote access enable
d.
> Please give me a hand with this as it is very important that I be able to
> use the Management Studio tools for my app development.
> Thanks in advance.
Does the connection error mention Named Pipes? If so, in the connection
dialog, click on Options, and under Connection Properties, make sure the
protocol explicitly states "TCP/IP".
Tracy McKibben
MCDBA
http://www.realsqlguy.com|||I had gone to options>>connection properties and I set he network protocol t
o
tcp/ip. I couldn't set the connect to database b/c it wasn't connecting with
the server.
Anything else?
"Tracy McKibben" wrote:

> Trevor Murphy wrote:
> Does the connection error mention Named Pipes? If so, in the connection
> dialog, click on Options, and under Connection Properties, make sure the
> protocol explicitly states "TCP/IP".
>
> --
> Tracy McKibben
> MCDBA
> http://www.realsqlguy.com
>|||Trevor Murphy wrote:
> I had gone to options>>connection properties and I set he network protocol
to
> tcp/ip. I couldn't set the connect to database b/c it wasn't connecting wi
th
> the server.
> Anything else?
>
What happens if you telnet to localhost:21433 ?
Tracy McKibben
MCDBA
http://www.realsqlguy.com|||Hi Tracy,
This is what I got. Forgive my ignorance, but I haven't used telnet in
decades.
Microsoft Telnet> open localhost:21433
Connecting To localhost:21433...Could not open connection to the host, on
port 23: Connect failed
Microsoft Telnet>
"Tracy McKibben" wrote:

> Trevor Murphy wrote:
> What happens if you telnet to localhost:21433 ?
>
> --
> Tracy McKibben
> MCDBA
> http://www.realsqlguy.com
>|||Trevor Murphy wrote:
> Hi Tracy,
> This is what I got. Forgive my ignorance, but I haven't used telnet in
> decades.
> Microsoft Telnet> open localhost:21433
> Connecting To localhost:21433...Could not open connection to the host, on
> port 23: Connect failed
> Microsoft Telnet>
>
Try this at the command line:
telnet localhost 21433
If it connects, you should get a blank DOS window with a blinking
cursor. Otherwise, you'll get some sort of error message - I'm curious
what that error message will be.
Tracy McKibben
MCDBA
http://www.realsqlguy.com

Sunday, February 19, 2012

Connecting jdbc driver from an applet

Hi,

I've found problems when executing

Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");

I get a java.lang.ClassNotFoundException, and I have done this steps:

1o I got the driver from msdn web page

2o I modified the classpath in Windows XP adding the path to the sqljdbc.jar, testing if there was any problems with blanks in the path, I tried to put the .jar file in a more simple folder, but it didn't work.

Perhaps I've to do something whith my policy.java or so archives to let applets do something about this but I have no idea.

Can someone help me? Thanks!

Hi there,

What IDE are you using (e.g. Eclipse, IntelliJ)? Are you coding and then running your app through the IDE?

If you are running your app through the IDE, something to be aware of is that most Java IDE's define their own classpath and by default don't use the CLASSPATH environment variable you set up in Windows.

To fix your problem, you need to configure the classpath used by your IDE so that it includes the sqljdbc.jar file.

If you're not sure how to do this then consult the doco that came with the IDE but if it's no help give us a buzz and we can probably work something out (I'm only familiar with Eclipse and IntelliJ though).

Hope that helps a bit, but sorry if it doesn't.
|||

Hi and thanks for your time,

I'm not using any kind of IDE. I've used to program with Eclipse but I'm not allow to do that now. With Eclipse I had add jar files other times without problems.I have to ask for it and I had this as my last solution.

So I'm doing it with a simple text editor and my JVM compiling everytime I want to. Then I open my applet with my internet explorer and that's when I get my error.

I'm looking for a solution with this conditions. Thanks

|||Hi there
I'm quite sure my problem is CLASSPATH, because I've found some examples where is tested my line code error and, in the catch block there is always a report like "You haven't registered SQL Server 2000 in the classpath" or so.
In my case, I have just add .jar file containing the driver, to the CLASSPATH variable. Does is it correct?

Thanks!
|||Yes, if the sqljdbc.jar file is not in the classpath then it needs to be there (if that's what you're asking).

So your classpath variable should be something like:

%classpath%;C:\JDBC\sqljdbc.jar

|||I've found another solution, and it seems to be working ok. Instead of using directly a new JDBC driver, I'm using the JDBC-ODBC generic bridge, so in the calling I should write

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver")

The only thing I' have to take in account is that I must give permissions to the applet in order to be able to get that driver and use the classes. I can do that if I modify my java.policy file.
|||

Hmmm, this may be a year too late, but for the sake of others running into the same problem...

First, I've had better luck getting the sqljdbc driver to work with SQL Server 2005, using

DriverManager.registerDriver(new com.microsoft.sqlserver.jdbc.SQLServerDriver());

rather than

Class.forName(...)

Second, I couldn't get this to work until I put an "ARCHIVE" parameter in the tag, referring specifically to the sqljdbc.jar:

<APPLET CODE="jdbcTest.class" ARCHIVE=sqljdbc.jar>

Next, I ran into a problem with running the applet from a web server that is *separate* from a remote database server (whose IP and port, below, I have changed in the interest of security):

Exception in thread "Thread-73" java.security.AccessControlException: access denied (java.net.SocketPermission 123.235.12.43:1234 connect,resolve)

As mentioned, the solution to this is to create a policy file, in this example named "jdbcTest.pol", that gives the applet the necessary permissions:

grant
{
permission java.net.SocketPermission "123.235.12.43:1234", "connect,resolve";
};

The problem with this seems to be that although it works when run under appletviewer, by specifying the policy file:

appletviewer -J-Djava.security.policy=jdbcTest.pol jdbcTest.html

It DOES NOT work when run in a browser! There does not seem to be a way to specify the policy file (for instance, as a parameter in the <APPLET> tag). A possible solution to this might be referred to in this snippet from the Java security FAQ:

"How can an applet open a network connection to a computer on the internet?

Applets are not allowed to open network connections to any computer, except for the host that provided the .class files. This is either the host where the html page came from, or the host specified in the codebase parameter in the applet tag, with codebase taking precendence."

So, it sounds like it might be possible to set the CODEBASE parameter to point to the remote database server (point to what, exactly, though?) or to have a page on the web server load the jdbcTest.class from a location on the remote database server. But I haven't got any of this to work yet! I'll post something here if I do. Otherwise, I'd be happy to hear from anyone who has got this to work.

The question is: Is it possible, given the security restrictions, to connect to a SQL Server running on a remote host from an applet running on a separate web server? If so, how?

Connecting jdbc driver from an applet

Hi,

I've found problems when executing

Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");

I get a java.lang.ClassNotFoundException, and I have done this steps:

1o I got the driver from msdn web page

2o I modified the classpath in Windows XP adding the path to the sqljdbc.jar, testing if there was any problems with blanks in the path, I tried to put the .jar file in a more simple folder, but it didn't work.

Perhaps I've to do something whith my policy.java or so archives to let applets do something about this but I have no idea.

Can someone help me? Thanks!

Hi there,

What IDE are you using (e.g. Eclipse, IntelliJ)? Are you coding and then running your app through the IDE?

If you are running your app through the IDE, something to be aware of is that most Java IDE's define their own classpath and by default don't use the CLASSPATH environment variable you set up in Windows.

To fix your problem, you need to configure the classpath used by your IDE so that it includes the sqljdbc.jar file.

If you're not sure how to do this then consult the doco that came with the IDE but if it's no help give us a buzz and we can probably work something out (I'm only familiar with Eclipse and IntelliJ though).

Hope that helps a bit, but sorry if it doesn't.
|||

Hi and thanks for your time,

I'm not using any kind of IDE. I've used to program with Eclipse but I'm not allow to do that now. With Eclipse I had add jar files other times without problems.I have to ask for it and I had this as my last solution.

So I'm doing it with a simple text editor and my JVM compiling everytime I want to. Then I open my applet with my internet explorer and that's when I get my error.

I'm looking for a solution with this conditions. Thanks

|||Hi there
I'm quite sure my problem is CLASSPATH, because I've found some examples where is tested my line code error and, in the catch block there is always a report like "You haven't registered SQL Server 2000 in the classpath" or so.
In my case, I have just add .jar file containing the driver, to the CLASSPATH variable. Does is it correct?

Thanks!
|||Yes, if the sqljdbc.jar file is not in the classpath then it needs to be there (if that's what you're asking).

So your classpath variable should be something like:

%classpath%;C:\JDBC\sqljdbc.jar

|||I've found another solution, and it seems to be working ok. Instead of using directly a new JDBC driver, I'm using the JDBC-ODBC generic bridge, so in the calling I should write

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver")

The only thing I' have to take in account is that I must give permissions to the applet in order to be able to get that driver and use the classes. I can do that if I modify my java.policy file.
|||

Hmmm, this may be a year too late, but for the sake of others running into the same problem...

First, I've had better luck getting the sqljdbc driver to work with SQL Server 2005, using

DriverManager.registerDriver(new com.microsoft.sqlserver.jdbc.SQLServerDriver());

rather than

Class.forName(...)

Second, I couldn't get this to work until I put an "ARCHIVE" parameter in the tag, referring specifically to the sqljdbc.jar:

<APPLET CODE="jdbcTest.class" ARCHIVE=sqljdbc.jar>

Next, I ran into a problem with running the applet from a web server that is *separate* from a remote database server (whose IP and port, below, I have changed in the interest of security):

Exception in thread "Thread-73" java.security.AccessControlException: access denied (java.net.SocketPermission 123.235.12.43:1234 connect,resolve)

As mentioned, the solution to this is to create a policy file, in this example named "jdbcTest.pol", that gives the applet the necessary permissions:

grant
{
permission java.net.SocketPermission "123.235.12.43:1234", "connect,resolve";
};

The problem with this seems to be that although it works when run under appletviewer, by specifying the policy file:

appletviewer -J-Djava.security.policy=jdbcTest.pol jdbcTest.html

It DOES NOT work when run in a browser! There does not seem to be a way to specify the policy file (for instance, as a parameter in the <APPLET> tag). A possible solution to this might be referred to in this snippet from the Java security FAQ:

"How can an applet open a network connection to a computer on the internet?

Applets are not allowed to open network connections to any computer, except for the host that provided the .class files. This is either the host where the html page came from, or the host specified in the codebase parameter in the applet tag, with codebase taking precendence."

So, it sounds like it might be possible to set the CODEBASE parameter to point to the remote database server (point to what, exactly, though?) or to have a page on the web server load the jdbcTest.class from a location on the remote database server. But I haven't got any of this to work yet! I'll post something here if I do. Otherwise, I'd be happy to hear from anyone who has got this to work.

The question is: Is it possible, given the security restrictions, to connect to a SQL Server running on a remote host from an applet running on a separate web server? If so, how?