School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 300,475 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,733 people online right now. Registration is fast and FREE... Join Now!




java application to access SQL database

 

java application to access SQL database, description is to design GUI to access record in the database

Gashayija

22 May, 2009 - 12:22 PM
Post #1

New D.I.C Head
*

Joined: 22 May, 2009
Posts: 3

i am student doing this project for my final year,but i managed to design a graphical user interface ,the main problem i am having is to make my GUI interface interact/talk to the database(MySQL).
i would love if any body could advice me what to do.

Thank you so much.

from Jean

User is offlineProfile CardPM
+Quote Post


jpete7683

RE: Java Application To Access SQL Database

22 May, 2009 - 08:32 PM
Post #2

D.I.C Head
**

Joined: 18 Apr, 2009
Posts: 63



Thanked: 7 times
My Contributions
Have you writen the code to create a connection to the Database? I guess I don't really understand what you mean by your GUI needing to communicate with the Database. Has there been any code writen to interact with the Database or is that what you are looking for?
User is offlineProfile CardPM
+Quote Post

PsychoCoder

RE: Java Application To Access SQL Database

22 May, 2009 - 10:15 PM
Post #3

Dyslexics Untie!
Group Icon

Joined: 26 Jul, 2007
Posts: 14,714



Thanked: 501 times
Dream Kudos: 11450
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net, jQuery

My Contributions
Dream.In.Code has a policy by which we prefer to see a good faith effort on your part before providing source code for homework assignments. Please post the code you have written in an effort to resolve the problem, and our members would be happy to provide some guidance. Be sure to include a description of any errors you are encountering as well.

Post your code like this: code.gif

Thanks.
User is offlineProfile CardPM
+Quote Post

Gashayija

RE: Java Application To Access SQL Database

14 Jun, 2009 - 01:24 PM
Post #4

New D.I.C Head
*

Joined: 22 May, 2009
Posts: 3

[quote name='jpete7683' date='22 May, 2009 - 08:32 PM' post='650730']
Have you writen the code to create a connection to the Database?
i havent written code yet becouse i dont know how to go about it?
how do you connect to database and selection,insert,delete to be enter in textArea
and result from database to be displayed below the typed textarea
User is offlineProfile CardPM
+Quote Post

Gashayija

RE: Java Application To Access SQL Database

15 Jun, 2009 - 10:00 AM
Post #5

New D.I.C Head
*

Joined: 22 May, 2009
Posts: 3

[quote name='Gashayija' date='14 Jun, 2009 - 01:24 PM' post='673856']
[quote name='jpete7683' date='22 May, 2009 - 08:32 PM' post='650730']
Have you writen the code to create a connection to the Database?
i havent written code yet becouse i dont know how to go about it?
how do you connect to database and selection,insert,delete to be enter in textArea
and result from database to be displayed below the typed textarea
[/quote]

here is my attechment of what i have done


import java.sql.*;

public class AllTableName{
public static void main(String[] args) {
System.out.println("Listing all table name in Database!");
Connection con = null;
String url = "jdbc:mysql://localhost:3306/";
String db = "mydatabase";
String driver = "com.mysql.jdbc.Driver";
String user = "root";
String pass = "najah2";
try{
Class.forName(driver);
con = DriverManager.getConnection(url+db, user, pass);
try{
DatabaseMetaData dbm = con.getMetaData();
String[] types = {"TABLE"};
ResultSet rs = dbm.getTables(null,null,"%",types);
System.out.println("Table name:");
while (rs.next()){
String table = rs.getString("TABLE_NAME");
System.out.println(table);
con.close();
}
}
catch (SQLException s){
System.out.println("No any table in the database");
}
}
catch (Exception e){
e.printStackTrace();
}
}
}







Attached File(s)
Attached File  import_java.doc ( 170k ) Number of downloads: 11
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/8/09 03:23AM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month