Java Forum / Databases / August 2005
Applet using jdbc (ms sqlserver)
Mika Myllyvirta - 16 Aug 2005 12:20 GMT 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 - 16 Aug 2005 16:55 GMT > Hi, > [quoted text clipped - 23 lines] > 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 - 17 Aug 2005 06:23 GMT 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
>> Hi, >> [quoted text clipped - 27 lines] > downloaded. Is it? > Joe Weinstein at BEA Systems Thomas Hawtin - 17 Aug 2005 07:06 GMT > 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
 Signature Unemployed English Java programmer http://jroller.com/page/tackline/
Mika Myllyvirta - 22 Aug 2005 06:56 GMT Hi Thomas,
I think that I might use this kind of solution for our dbapplet.
Thanks for the reply, Mika
>> 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 [quoted text clipped - 11 lines] > > Tom Hawtin Frank Brouwer - 23 Aug 2005 15:06 GMT 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
> Hi, > [quoted text clipped - 23 lines] > Best Regards, > Mika Mika Myllyvirta - 24 Aug 2005 06:11 GMT 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
> Hi Mika, > [quoted text clipped - 37 lines] >>Best Regards, >>Mika Luke Webber - 24 Aug 2005 06:50 GMT > Hi Frank, > [quoted text clipped - 5 lines] > > 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 - 24 Aug 2005 10:20 GMT 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
>> Hi Frank, >> [quoted text clipped - 13 lines] > > Luke Frank Brouwer - 24 Aug 2005 13:12 GMT 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/
 Signature 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
> Hi Frank, > [quoted text clipped - 49 lines] >>>Best Regards, >>>Mika Thomas Hawtin - 24 Aug 2005 13:55 GMT > 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
 Signature Unemployed English Java programmer http://jroller.com/page/tackline/
Mika Myllyvirta - 25 Aug 2005 05:57 GMT 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
> Hi Mika, > [quoted text clipped - 5 lines] > > Look at: http://www.quadbase.com/
Free MagazinesGet these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...
|
|
|