Results 1 to 3 of 3
Thread: Database
- 07-25-2010, 05:32 PM #1
Member
- Join Date
- Jul 2010
- Posts
- 1
- Rep Power
- 0
Database
Hi I have created a class as below
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.logging.Level;
import java.util.logging.Logger;
public class NewClass1 {
{
try {
Class.forName("sun.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/ant", "root", "")
try {
Statement st = con.createStatement();
ResultSet rs = st.executeQuery("SELECT*FROM SF");
String jTextField1 = rs.getString("");
} catch (SQLException ex) {
Logger.getLogger(NewClass1.class.getName()).log(Le vel.SEVERE, null, ex);
}
} catch (SQLException ex) {
Logger.getLogger(NewClass1.class.getName()).log(Le vel.SEVERE, null, ex);
} catch (ClassNotFoundException ex) {
Logger.getLogger(NewClass1.class.getName()).log(Le vel.SEVERE, null, ex);
}
}
}
And created a form with a jTextField, a jbutton and a jtable. The scope is that when I type a name in the textfieldand press the button, the rest of the information that matches the data in the field will populate the table. I the data is stored in a database.
I don't know how to continue from here, any help please.Last edited by tech; 07-25-2010 at 05:40 PM.
- 07-25-2010, 05:48 PM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,606
- Blog Entries
- 7
- Rep Power
- 17
I don't see a JTable anywhere, nor any other component. All I see is this:
Do you really have a database column labeled ""? First check if you can fetch your data from your database.Java Code:String jTextField1 = rs.getString("");
kind regards,
Jos
- 07-25-2010, 05:49 PM #3
You need to work on the GUI part of your program. Use the JFrame class and then add the components to it that you need.
Read the Tutorial at The Java™ Tutorials about how to write GUI.
Also use Search on this forum for many samples of code for GUI.
Similar Threads
-
xml to database from xml rpc
By kievari in forum JDBCReplies: 1Last Post: 12-11-2009, 12:14 AM -
database
By kswiss in forum AWT / SwingReplies: 0Last Post: 03-26-2009, 11:51 AM -
help with database
By fahien_akim in forum NetBeansReplies: 0Last Post: 03-07-2009, 01:44 PM -
How to convert access database to mysql database?
By vrk in forum Advanced JavaReplies: 2Last Post: 02-11-2009, 04:43 AM -
Database in a PDA
By percivalwcy in forum JDBCReplies: 2Last Post: 08-08-2007, 03:10 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks