Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

[java]MySQL JDBC driver

  1. May 27, 2006 #1
    need help with some coding


    public void createTable(String tableName, String[] columnNames, String[] columnType, String[] Keys) throws SQLException {

    try {
    stmt = conn.createStatement();
    String sql = <need help here>
    stmt.executeUpdate(sql);
    }
    catch (SQLException e) {
    }
    }

    not sure how to type the code for String sql
    with columnNames, columnType as arrays...
    should i actually for-loop it??
     
  2. jcsd
  3. May 27, 2006 #2
    so far.. i got

    String sql = "CREATE TABLE " + tableName + "(" + columnNames + " VARCHAR(32))";

    i know it's wrong , but then not sure how i should write it...
    another word... stucked :)
     
  4. May 27, 2006 #3
    PHP:
    String sql = "CREATE TABLE " + tableName + " (";
    for (int i = 0; i < columnNames.length; i++) {
        sql += columnNames[i] + " " + columnType[i] + ",";
    }
    sql += ");";
     
     
  5. May 27, 2006 #4
    thx wave ^_^
    and can someone actually teach me..

    how to retrieve a string data from MySQL database, and display it in a swing GUI JDialog?? pop-up

    and a swing GUI that displays some particular information from MySQL database (in table)
     
  6. May 28, 2006 #5
    so far i got something like...
    PHP:

    import java.awt.*;
    import javax.swing.*;

    public class MainGUI extends JFrame {
    JDialog welcome Window;

    public MainGUI() {
    super();
    // unnecessary codes, no problem here

    }

    public void initComponents() {
    this.welcomeWindow = new JDialog();
    welcomeWindow.showMessageDialog(null, "Welcome " + username);

    }

    }
     
    well my codes something like this rite now

    not too sure... if i want to fetch username from the MySQL database

    any clue??? any one can help me a bit? :D
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?



Similar Discussions: [java]MySQL JDBC driver
  1. Help with MySQL (Replies: 3)

  2. Using aliases in MYSQL (Replies: 3)

Loading...