Results 1 to 2 of 2

Thread: java mysql

  1. #1
    seredi is offline Member
    Join Date
    Sep 2011
    Posts
    14
    Rep Power
    0

    Default java mysql

    how to create a database table, where the table name is assigned from the user input variable.

    it is something like value of variable JtextField.getText() should be used as name of the table as CREATE TABLE JTextField.getText() is it possible and how to do it.

  2. #2
    ballantony is offline Member
    Join Date
    Oct 2011
    Posts
    5
    Rep Power
    0

    Default Re: java mysql

    The following will create a table with the fields from String field (in this case Surname) and Forename. There are better ways, those "'s in String query are a pain to get right.



    Statement statement = con.createStatement();
    String field = "Surname";

    String query = "Create Table Pupil(" + field + " CHAR(30), Forename CHAR(30))";
    statement.executeUpdate(query);

Similar Threads

  1. Java/mysql/jsp
    By samanthamaryhorgan in forum Advanced Java
    Replies: 1
    Last Post: 02-25-2010, 06:28 PM
  2. Java and MySQL
    By Abder-Rahman in forum JDBC
    Replies: 6
    Last Post: 04-21-2009, 09:55 AM
  3. MySQL/JDBC Mysql query output
    By thelinuxguy in forum Advanced Java
    Replies: 4
    Last Post: 02-13-2009, 01:57 AM
  4. java to mysql
    By thamizhisai in forum New To Java
    Replies: 12
    Last Post: 04-28-2008, 07:48 AM
  5. java to mysql
    By thamizhisai in forum Advanced Java
    Replies: 1
    Last Post: 04-26-2008, 08:21 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •