Applet using jdbc (ms sqlserver)  
Author Message
Mika Myllyvirta





PostPosted: 2005-8-16 19:21:00 Top

java-programmer, Applet using jdbc (ms sqlserver) Hi,

After reading lots of docs, a got the impression that it is possible to
write an Java Applet, that uses jdbc to connect to MS SQLServer (Without
flushing all security permissions down to drain).

Here is what I've done:

1. Downloaded the Microsoft JDBC driver for SQL Server 2000 SP 3.
2. Downloaded the app from Microsoft's site:
http://support.microsoft.com/default.aspx?scid=kb;en-us;313100
3. Tried to compile.

I get the java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for
JDBC]Error establishing socket.

I have tested every possible error that I can find in MS's site. I have
tried to alter policies granting "permission java.net.SocketPermission",
with no luck. I think that before granting this permission, I also got
some security exceptions..

So here's my question: is it possible to create an applet (UnTrusted)
that uses SQL server, that can be run in browser, that doesn't need any
security alternations?

Best Regards,
Mika
 
Joe Weinstein





PostPosted: 2005-8-16 23:55:00 Top

java-programmer >> Applet using jdbc (ms sqlserver)

Mika Myllyvirta wrote:

> Hi,
>
> After reading lots of docs, a got the impression that it is possible to
> write an Java Applet, that uses jdbc to connect to MS SQLServer (Without
> flushing all security permissions down to drain).
>
> Here is what I've done:
>
> 1. Downloaded the Microsoft JDBC driver for SQL Server 2000 SP 3.
> 2. Downloaded the app from Microsoft's site:
> http://support.microsoft.com/default.aspx?scid=kb;en-us;313100
> 3. Tried to compile.
>
> I get the java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for
> JDBC]Error establishing socket.
>
> I have tested every possible error that I can find in MS's site. I have
> tried to alter policies granting "permission java.net.SocketPermission",
> with no luck. I think that before granting this permission, I also got
> some security exceptions..
>
> So here's my question: is it possible to create an applet (UnTrusted)
> that uses SQL server, that can be run in browser, that doesn't need any
> security alternations?
>
> Best Regards,
> Mika

Hi. The DBMS has to be running on the machine from which the applet was
downloaded. Is it?
Joe Weinstein at BEA Systems

 
Mika Myllyvirta





PostPosted: 2005-8-17 13:23:00 Top

java-programmer >> Applet using jdbc (ms sqlserver) Hi Joe,

The applet is not running on a same server with SQLServer, so this might
be the case (I'll test it a bit later). But, if I wanted the applet to
run from the web-server and connecting to another database-server, what
should I do? I don't want to alter security policies (because, clients
might not be able to do this, and for security reasons).

Could WebStart Application or Trusted applet connect to different db-server?

I doubt that db-applet's on the web are installed on a server which has
both web & sql backend installed on it.. Or I might be mistaken.

Thank you for your reply.

Best Regards,
Mika Myllyvirta


Joe Weinstein wrote:
>
>
> Mika Myllyvirta wrote:
>
>> Hi,
>>
>> After reading lots of docs, a got the impression that it is possible
>> to write an Java Applet, that uses jdbc to connect to MS SQLServer
>> (Without flushing all security permissions down to drain).
>>
>> Here is what I've done:
>>
>> 1. Downloaded the Microsoft JDBC driver for SQL Server 2000 SP 3.
>> 2. Downloaded the app from Microsoft's site:
>> http://support.microsoft.com/default.aspx?scid=kb;en-us;313100
>> 3. Tried to compile.
>>
>> I get the java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for
>> JDBC]Error establishing socket.
>>
>> I have tested every possible error that I can find in MS's site. I
>> have tried to alter policies granting "permission
>> java.net.SocketPermission", with no luck. I think that before granting
>> this permission, I also got some security exceptions..
>>
>> So here's my question: is it possible to create an applet (UnTrusted)
>> that uses SQL server, that can be run in browser, that doesn't need
>> any security alternations?
>>
>> Best Regards,
>> Mika
>
>
> Hi. The DBMS has to be running on the machine from which the applet was
> downloaded. Is it?
> Joe Weinstein at BEA Systems
>
 
 
Thomas Hawtin





PostPosted: 2005-8-17 14:06:00 Top

java-programmer >> Applet using jdbc (ms sqlserver) Mika Myllyvirta wrote:
>
> The applet is not running on a same server with SQLServer, so this might
> be the case (I'll test it a bit later). But, if I wanted the applet to
> run from the web-server and connecting to another database-server, what
> should I do? I don't want to alter security policies (because, clients
> might not be able to do this, and for security reasons).

You can use a simple proxy to forward connection to the relevant port.
If you're using Linux/BSD then iptables/ipchains/ipfw will do it nicely.
Or a router could do it.

Of course then you have the problem that your database is exposed, but
that's unavoidable with such a 2-tier system.

Tom Hawtin
--
Unemployed English Java programmer
http://jroller.com/page/tackline/
 
 
Mika Myllyvirta





PostPosted: 2005-8-22 13:56:00 Top

java-programmer >> Applet using jdbc (ms sqlserver) Hi Thomas,

I think that I might use this kind of solution for our dbapplet.

Thanks for the reply,
Mika

Thomas Hawtin wrote:
> Mika Myllyvirta wrote:
>
>>
>> The applet is not running on a same server with SQLServer, so this
>> might be the case (I'll test it a bit later). But, if I wanted the
>> applet to run from the web-server and connecting to another
>> database-server, what should I do? I don't want to alter security
>> policies (because, clients might not be able to do this, and for
>> security reasons).
>
>
> You can use a simple proxy to forward connection to the relevant port.
> If you're using Linux/BSD then iptables/ipchains/ipfw will do it nicely.
> Or a router could do it.
>
> Of course then you have the problem that your database is exposed, but
> that's unavoidable with such a 2-tier system.
>
> Tom Hawtin
 
 
Frank Brouwer





PostPosted: 2005-8-23 22:07:00 Top

java-programmer >> Applet using jdbc (ms sqlserver) Hi Mika,

As far as I know it is impossible to use jdbc from an applet. This is
because of the security implementation in applets where it is not possible
to use system resources. If you want to use applets to communicate with a
database you wil have to put a server between the two (that's better any
way), where the applets communicates to the server and the server to the
database and the same route back.

Hope it helps....

Regards,
Frank Brouwer

"Mika Myllyvirta" <email***@***.com> wrote in
message news:p_jMe.132$email***@***.com...
> Hi,
>
> After reading lots of docs, a got the impression that it is possible to
> write an Java Applet, that uses jdbc to connect to MS SQLServer (Without
> flushing all security permissions down to drain).
>
> Here is what I've done:
>
> 1. Downloaded the Microsoft JDBC driver for SQL Server 2000 SP 3.
> 2. Downloaded the app from Microsoft's site:
> http://support.microsoft.com/default.aspx?scid=kb;en-us;313100
> 3. Tried to compile.
>
> I get the java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for
> JDBC]Error establishing socket.
>
> I have tested every possible error that I can find in MS's site. I have
> tried to alter policies granting "permission java.net.SocketPermission",
> with no luck. I think that before granting this permission, I also got
> some security exceptions..
>
> So here's my question: is it possible to create an applet (UnTrusted) that
> uses SQL server, that can be run in browser, that doesn't need any
> security alternations?
>
> Best Regards,
> Mika


 
 
Mika Myllyvirta





PostPosted: 2005-8-24 13:11:00 Top

java-programmer >> Applet using jdbc (ms sqlserver) Hi Frank,

I managed to create an applet that uses
net.sourceforge.jtds.jdbc.Driver. It works fine communicating with MS
Sql Server. Now I am trying to create reports for the applet. I found
Crystal Clear report engine (pure java), that hopefully solves our
reporting issues.

Not sure if Crystal Reports would be better, but I'll test the CC first.

Best Regards,
Mika Myllyvirta

Frank Brouwer wrote:
> Hi Mika,
>
> As far as I know it is impossible to use jdbc from an applet. This is
> because of the security implementation in applets where it is not possible
> to use system resources. If you want to use applets to communicate with a
> database you wil have to put a server between the two (that's better any
> way), where the applets communicates to the server and the server to the
> database and the same route back.
>
> Hope it helps....
>
> Regards,
> Frank Brouwer
>
> "Mika Myllyvirta" <email***@***.com> wrote in
> message news:p_jMe.132$email***@***.com...
>
>>Hi,
>>
>>After reading lots of docs, a got the impression that it is possible to
>>write an Java Applet, that uses jdbc to connect to MS SQLServer (Without
>>flushing all security permissions down to drain).
>>
>>Here is what I've done:
>>
>>1. Downloaded the Microsoft JDBC driver for SQL Server 2000 SP 3.
>>2. Downloaded the app from Microsoft's site:
>> http://support.microsoft.com/default.aspx?scid=kb;en-us;313100
>>3. Tried to compile.
>>
>>I get the java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for
>>JDBC]Error establishing socket.
>>
>>I have tested every possible error that I can find in MS's site. I have
>>tried to alter policies granting "permission java.net.SocketPermission",
>>with no luck. I think that before granting this permission, I also got
>>some security exceptions..
>>
>>So here's my question: is it possible to create an applet (UnTrusted) that
>>uses SQL server, that can be run in browser, that doesn't need any
>>security alternations?
>>
>>Best Regards,
>>Mika
>
>
>
 
 
Luke Webber





PostPosted: 2005-8-24 13:51:00 Top

java-programmer >> Applet using jdbc (ms sqlserver) Mika Myllyvirta wrote:
> Hi Frank,
>
> I managed to create an applet that uses
> net.sourceforge.jtds.jdbc.Driver. It works fine communicating with MS
> Sql Server. Now I am trying to create reports for the applet. I found
> Crystal Clear report engine (pure java), that hopefully solves our
> reporting issues.
>
> Not sure if Crystal Reports would be better, but I'll test the CC first.

Ugh. Crystal Reports is very well named. It's incredibly fragile. Oh,
and it needs to be installed on the client (Windows only!) system.
Forgedabahtit.

You might consider Jasper Reports, though.

Luke
 
 
Mika Myllyvirta





PostPosted: 2005-8-24 17:20:00 Top

java-programmer >> Applet using jdbc (ms sqlserver) Hi Luke,

Thank you for suggesting Jasper Reports.

I have been testing Jasper Reports. Have anybody added JR to an applet?
Some help would be needed here..

I've created a report file with iReport-tool. Added these jar's for
JasperReports:
commons-beanutils.jar
commons-beanutils-bean-collections.jar
commons-beanutils-core.jar
commons-collections-3.1.jar
commons-digester-1.7.jar
commons-logging.jar
commons-logging-api.jar
commons-jasperreports-1.0.0.jar
commons-jasperreports-1.0.0-applet.jar

Trying to view the report:
try{
JasperViewer jv = new JasperViewer("test.jrxml",true);
} catch (Exception e){ e.printStackTrace(); } }

I get the following:
24.8.2005 12:17:20 org.apache.commons.digester.Digester startElement
SEVERE: Begin event threw exception
java.lang.ClassCastException
at
net.sf.jasperreports.engine.xml.JRPrintElementFactory.createObject(JRPrintElementFactory.java:62)

What might be the problem? Have anybody created a tutorial/example
applet about reporting from an applet? somebody?


Best Regards,
Mika Myllyvirta

Luke Webber wrote:
> Mika Myllyvirta wrote:
>
>> Hi Frank,
>>
>> I managed to create an applet that uses
>> net.sourceforge.jtds.jdbc.Driver. It works fine communicating with MS
>> Sql Server. Now I am trying to create reports for the applet. I found
>> Crystal Clear report engine (pure java), that hopefully solves our
>> reporting issues.
>>
>> Not sure if Crystal Reports would be better, but I'll test the CC first.
>
>
> Ugh. Crystal Reports is very well named. It's incredibly fragile. Oh,
> and it needs to be installed on the client (Windows only!) system.
> Forgedabahtit.
>
> You might consider Jasper Reports, though.
>
> Luke
 
 
Frank Brouwer





PostPosted: 2005-8-24 20:12:00 Top

java-programmer >> Applet using jdbc (ms sqlserver) Hi Mika,

Ah, I asume your not running the applet in a browser then.

For a reporter in Java you might also consider Esspress Reports from
Quadbase, it's pure java and you can integrate it fully into your
application. We use it for 3 years now with our product Trimergo.

Look at: http://www.quadbase.com/

--
Regards,
Frank Brouwer

_________________________________________________

Trimergo BV
Project Manufacturing Software

Amersfoortseweg 15 C
7313 AB Apeldoorn, Netherlands
Telefoon: +31 55 - 577 7373
Telefax: + 31 55 - 577 7370

www.trimergo.com

"Mika Myllyvirta" <email***@***.com> wrote in
message news:TjTOe.21$email***@***.com...
> Hi Frank,
>
> I managed to create an applet that uses net.sourceforge.jtds.jdbc.Driver.
> It works fine communicating with MS Sql Server. Now I am trying to create
> reports for the applet. I found Crystal Clear report engine (pure java),
> that hopefully solves our reporting issues.
>
> Not sure if Crystal Reports would be better, but I'll test the CC first.
>
> Best Regards,
> Mika Myllyvirta
>
> Frank Brouwer wrote:
>> Hi Mika,
>>
>> As far as I know it is impossible to use jdbc from an applet. This is
>> because of the security implementation in applets where it is not
>> possible to use system resources. If you want to use applets to
>> communicate with a database you wil have to put a server between the two
>> (that's better any way), where the applets communicates to the server and
>> the server to the database and the same route back.
>>
>> Hope it helps....
>>
>> Regards,
>> Frank Brouwer
>>
>> "Mika Myllyvirta" <email***@***.com> wrote in
>> message news:p_jMe.132$email***@***.com...
>>
>>>Hi,
>>>
>>>After reading lots of docs, a got the impression that it is possible to
>>>write an Java Applet, that uses jdbc to connect to MS SQLServer (Without
>>>flushing all security permissions down to drain).
>>>
>>>Here is what I've done:
>>>
>>>1. Downloaded the Microsoft JDBC driver for SQL Server 2000 SP 3.
>>>2. Downloaded the app from Microsoft's site:
>>> http://support.microsoft.com/default.aspx?scid=kb;en-us;313100
>>>3. Tried to compile.
>>>
>>>I get the java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for
>>>JDBC]Error establishing socket.
>>>
>>>I have tested every possible error that I can find in MS's site. I have
>>>tried to alter policies granting "permission java.net.SocketPermission",
>>>with no luck. I think that before granting this permission, I also got
>>>some security exceptions..
>>>
>>>So here's my question: is it possible to create an applet (UnTrusted)
>>>that uses SQL server, that can be run in browser, that doesn't need any
>>>security alternations?
>>>
>>>Best Regards,
>>>Mika
>>
>>

 
 
Thomas Hawtin





PostPosted: 2005-8-24 20:56:00 Top

java-programmer >> Applet using jdbc (ms sqlserver) Frank Brouwer wrote:
>
> Ah, I asume your not running the applet in a browser then.

Many (most) JDBC drivers are 'pure java' and requires no extra
permissions than connecting a TCP socket to the database server. So
putting the web and database servers on the same machine (or at least
same IP address) will allow an applet to use JDBC directly. In fact, I
believe the source for java.sql.DriverManager talks about applets directly.

Tom Hawtin
--
Unemployed English Java programmer
http://jroller.com/page/tackline/
 
 
Mika Myllyvirta





PostPosted: 2005-8-25 12:57:00 Top

java-programmer >> Applet using jdbc (ms sqlserver) Hi Frank,

I'll test the Quadbase Reports also. I never realized that there are so
many different pure Java reporting engines in the market.. Probably I
should have googled before asking.. :) Anyway Thank You for telling me
about another solution for our reporting needs!

As Thomas stated in his above message, it is possible to use
sql-database in an applet (even untrusted!), least in my experience. I
have been developing for Java some years ago, but now just reacently I
came back to the Java community and you'll never know how much I have
forgot about Java.. And how much Java and Java related tools have
evolved in a few years!

Thanks to everybody for your help.


Best Regards,
Mika Myllyvirta


Frank Brouwer wrote:
> Hi Mika,
>
> Ah, I asume your not running the applet in a browser then.
>
> For a reporter in Java you might also consider Esspress Reports from
> Quadbase, it's pure java and you can integrate it fully into your
> application. We use it for 3 years now with our product Trimergo.
>
> Look at: http://www.quadbase.com/
>