wood burning stoves*
The moose likes Applets and the fly likes Database connection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "Database connection" Watch "Database connection" New topic
Author

Database connection

R Sugan
Ranch Hand

Joined: Mar 13, 2009
Posts: 48
Hi,
I tried one small application in java applet.Now i need to connect database.Is it possible.
How can i integrate java applet and mysql database.Please give me sample code.



Regards,
Suganya.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41102
    
  45
JDBC works the same way in an applet as it works in any other Java code. You'll need to add the driver jar file to the applet tag's "archive" attribute.

But using JDBC in an applet is generally considered bad practice, since it constitutes a security risk. It might be OK for an intranet, though.

One thing to be aware of is that applets can only connect to the server where they were served from. So the DB needs to run on the same machine as the web server that hosts the applet, or it won't work.


Ping & DNS - my free Android networking tools app
R Sugan
Ranch Hand

Joined: Mar 13, 2009
Posts: 48
Hi,

Thanks for your response.I got this output.Now i need to get the values from mysql database through combo box in applet java.Please guide me to get this output.




Regards,
Suganya
ujjwal soni
Ranch Hand

Joined: Mar 28, 2007
Posts: 403
Hi,

Here's a nice example for connecting java program using mysql




Cheers!!!
Ujjwal B Soni <baroda, gujarat, india> <+919909981973>
"Helping hands are better than praying lips......"
R Sugan
Ranch Hand

Joined: Mar 13, 2009
Posts: 48
Hi ujjwal soni,

Thanks for your reply.I worked this sample code and i got this output.Now i need to get the values from mysql database through combo box in applet java code.
Please guide me to get this output.

Regards,
Suganya.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41102
    
  45
Now i need to get the values from mysql database through combo box in applet java code.

It's not clear what that means. Are you asking how to add a combo box to an applet, or are you asking how to create a DB query that includes a value that gets selected by such a UI element, or something else? What do you have so far, and where are you stuck making progress?
ujjwal soni
Ranch Hand

Joined: Mar 28, 2007
Posts: 403
[ UD: We appreciate your efforts to help, but the ranch is NotACodeMill. We don't want to hand out solutions, but make sure that people actually learn something in the process ... which is much more likely if they need to figure out stuff on their own. ]
R Sugan
Ranch Hand

Joined: Mar 13, 2009
Posts: 48
Hi,
Thanks.I need to get the values from database.I will explain you in detail.I tried to send sms through
GSM modem.I will send message using at commands through GSM modem to single number one by one successfully.
But if i need to send a message to more numbers at a time.so i tried to get numbers from database and i will click send button
the message will be send to the corresponding number.Now am trying code for getting the values from database and get the
values successfully but i am unable to open a serial port at the same time.How to solve this problem.

The following code is



please assist me to solve this problem.


Regards,
suganya.

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41102
    
  45
That's about 500 lines of code more than you can expect anyone to go through and try to make sense of.

Suddenly there's talk of GSM and serial ports - is this still a question about DB connectivity? What, exactly, is working, and what, exactly, is not working?
ujjwal soni
Ranch Hand

Joined: Mar 28, 2007
Posts: 403
Do you want to populate combo with database values or get sms thing done ? Can you be clear with your question please ?
ujjwal soni
Ranch Hand

Joined: Mar 28, 2007
Posts: 403
ujjwal soni wrote:[ UD: We appreciate your efforts to help, but the ranch is NotACodeMill. We don't want to hand out solutions, but make sure that people actually learn something in the process ... which is much more likely if they need to figure out stuff on their own. ]


Thanks Dittmer, will take care from next time.......

R Sugan
Ranch Hand

Joined: Mar 13, 2009
Posts: 48
Hi,
Thanks.Actually am trying to send sms through GSM modem using the above applet java code.I have
send message to a single person successfully through this above code.Now i need to send more number
of person at a time so i am using database.So i get the values from database successfully.At the same
time i can't able to open the serial port.This is my problem.Am implementing the code for get the
database value.I need to get the values(Phonenumber) from database and also send the message to
corresponding number through this above code(Gsm modem).This is my need.Please assist me to solve this
problem.



Regards,
Suganya.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41102
    
  45
So all DB connection problems are now solved, and the issue is purely how to connect to a GSM device using a serial connection? If so, what does "i can't able to open the serial port" mean - how, exactly, have you tried, and what, exactly, was the result?
ujjwal soni
Ranch Hand

Joined: Mar 28, 2007
Posts: 403
Hi,

I gone through your code and was not able to find out a function from where phone number gets passed to GSM modem, can you help me to find that function ?

Also, can you check that how phone numbers (multiple ones) are to be passed in GSM modem from any reference manual or CD that came with your modem ? Is it to be passed comma separated or using other delimiter.


R Sugan
Ranch Hand

Joined: Mar 13, 2009
Posts: 48
Hi,

Yes.Solved all DB connection problems.I can able to get the values from DB through applet java.
That is not issue.Now i need to send the message through GSM modem successfully without DB connection.
I tried to send the message through GSM modem with DB connection code and i get the values from DB
successfully but i can't able to open serial port connection the same code.How to solve this problem.
Please assist me to solve this problem.





Regards,
Suganya.
ujjwal soni
Ranch Hand

Joined: Mar 28, 2007
Posts: 403
You mentioned in your first post that you are able to send sms using a single user, is it working now ?

What error are you getting if you send comma seperated multiple phone numbers ?

Are you sure you installed your modem correctly with right settings ?

Are you able to query the modem from windows control panel ?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41102
    
  45
Ulf Dittmer wrote:what does "i can't able to open the serial port" mean - how, exactly, have you tried, and what, exactly, was the result?
R Sugan
Ranch Hand

Joined: Mar 13, 2009
Posts: 48
Hi,

Am not getting any error message.But i can't send the message to mobile(can't open serial connection) when am using the DB code.Actually
i tried to send the message to phone number through GSM modem without DB code.I can able to type at commands(GSM modem commands)
and send the messages successfully.But am also tried to send the message to phone number through GSM modem with DB code i can't able to
type at commands(GSM modem commands) but i get the values from DB.Already attached my code to you.I am trying the same code.
Then i tried to attach my output screen but am getting error message.

Files with the extension .doc are not allowed as attachment in the message.

How to attach my output screen.Please guide me to solve this issue.



Regards,
Suganya.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41102
    
  45
Nobody is going to try to wade through 563 lines of code. If it contains something that you want to draw our attention to, then post a short, relevant, code excerpt. Be sure to indicate what the current values are that the code uses, and how it does not do what you expected it to do.

How to attach my output screen.

Only images can be attached - take a screenshot and attach that.
ujjwal soni
Ranch Hand

Joined: Mar 28, 2007
Posts: 403
i tried to send the message to phone number through GSM modem without DB code.I can able to type at commands(GSM modem commands)
and send the messages successfully.But am also tried to send the message to phone number through GSM modem with DB code i can't able to
type at commands(GSM modem commands) but i get the values from DB.Already attached my code to you.I am trying the same code.
Then i tried to attach my output screen but am getting error message.


Are you trying this from any readymade interface, that is an exe or something or using a java code ?

if so, then can you post that code please ?
R Sugan
Ranch Hand

Joined: Mar 13, 2009
Posts: 48
Hi


Thanks for your response.The code snippet in "Sms_GUI.java" is as follows:




I have tried this above code and am getting values from database successfully at the same time but i can't able to type
at commands.That is not a exe.Am trying readymade interface.Please assist me to solve this issue.



Regards,
Suganya.
ujjwal soni
Ranch Hand

Joined: Mar 28, 2007
Posts: 403
The code you sent contains database connection code too,

I want to see the code which is working for you, that is using single phone number as you told.

Can you post that code please ?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Database connection
 
Similar Threads
hi, i have problem in reading data
Crypted Strings in a file
Why we choose java?
What java methods to use?
i love java