Discussion Locked

How to connect a database to Applet

0 helpful
7 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hello
I have a database consisting of some values say some counts.I have to use this counts to plot barcharts. I think I can draw barchart using Applet. But may I know how to connect database thru applets. I can't use Frames becaz I want the barcharts in browser.

Thank U
Bhuns

7 replies

by al_<al

I am not a Java programmer, but I have found a way to feed data to an applet written by someone else: I simply use a database connected development environment (any will do: Cold Fusion, ASP, Tango, Perl, etc.). I query my tables and then format theresults using HTML applet parameter syntax, for example:

<applet archive="someapp.jar" code="someapp.class" width="135" height="225">
< %
Response.write '<param name="floatmode" value="' + floatvar +'">')
%>
</applet>

Assuming *floatvar* has been assigned previously, the applet gets the dynamic data as the page loads and all is right in the world.

JDBC is another topic to explore; it would allow you direct access to a database within the Java API, but I leave that to those who know more about it.

HTH

by francodacosta

I'm not a java programer but this is how to connect to an ADO compilant DB using microsoft JScript.

var myConnect = "Provider=sqloledb;Data Source=" +
Request.ServerVariables("SERVER_NAME") + ";" +
"Initial Catalog=Northwind;User Id=sa;Password=;";
mySQL = "select * from Customers;";
showBlank = " ";
showNull = "-NULL-";

var connTemp = Server.CreateObject("ADODB.Connection");
connTemp.Open(myConnect);
rsTemp = Server.CreateObject("ADODB.Recordset");
rsTemp.ActiveConnection = connTemp;
rsTemp.CursorLocation = adUseClient;
rsTemp.CursorType = adOpenKeyset;
rsTemp.LockType = adLockOptimistic;
rsTemp.Source = mySQL;
rsTemp.Open();

I hope this was usefull

by tech geek

It depends what type of database you are trying to connect to. If it is an Oracle database you need to use the oracle thin. You will need to get a JDBC driver from the vendor of the database, unless you want to connect to an ODBC database. An ODBC driver is already part of the java core. It is called something like com.sun.jdbc.odbc
If you go to the website www.java.sun.com you will find tons of info. on java. If you search on this page for jdbc you should be able to quickly find an example of the syntax, but if you don't let me know I will post an example.

This discussion is closed to new replies.