Results 1 to 6 of 6
  1. #1
    efoikonom is offline Member
    Join Date
    Apr 2013
    Posts
    10
    Rep Power
    0

    Default state the create table name

    Hi,
    i made a program in java that it takes an excel file and store its data in a database. When i state where the file is its like this:
    Java Code:
    String filename = "test5.xls";
    		String path = "C:\\Users\\myfiles\\Documents\\";
    But when i call the create table and i state the filename of the excel file because it it test.xls the mysql command shows error!
    Is there any way to rename the file before i create the table or to read only the "test" without the .xls?

    Thank you in advance!

  2. #2
    efoikonom is offline Member
    Join Date
    Apr 2013
    Posts
    10
    Rep Power
    0

    Default Re: state the create table name

    the create table command is:

    try
    {
    String all = org.apache.commons.lang3.StringUtils.join(allField s, ",");
    String createTableStr = "CREATE TABLE " + "table5.xls" + " (" + all + ")";

    System.out.println( "Create a new table in the database" );
    stmt.executeUpdate( createTableStr );
    }

  3. #3
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,798
    Rep Power
    19

    Default Re: state the create table name

    Look at the String API.
    There are methods in there that will allow you to take a substring, and allow you to find the first index of a particular character.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  4. #4
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    7

    Default Re: state the create table name

    Tolls, there are already plenty threads from the OP about that topic here and at OTN.
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  5. #5
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,798
    Rep Power
    19

    Default Re: state the create table name

    Oh, I thought I recognised it, but couldn't place it.

    Oh well, I'll try to remember to ignore them then...
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  6. #6
    efoikonom is offline Member
    Join Date
    Apr 2013
    Posts
    10
    Rep Power
    0

    Default Re: state the create table name

    I have done this:

    //String filename = "C:\\Users\\myfiles\\Documents\\test5.xls";
    String fullPath = "C:\\Users\\myfiles\\Documents\\test5.xls";
    String filename = "test5.xls";
    String filenamewithoutext = filename.replaceFirst("[.][^.]+$", "");

    but plenty of errors come up!
    C:\Users\myfiles\Documents\test5.xlstest5.xls (The system cannot find the file specified)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(Unknown Source)
    at java.io.FileInputStream.<init>(Unknown Source)
    at readexcel.main(readexcel.java:34)

Similar Threads

  1. how to create table for each user
    By abhi7080 in forum New To Java
    Replies: 3
    Last Post: 01-04-2012, 07:42 AM
  2. Replies: 2
    Last Post: 02-14-2011, 02:27 PM
  3. Replies: 6
    Last Post: 02-05-2010, 04:53 PM
  4. how to create a table using gui
    By dandon_1912 in forum SWT / JFace
    Replies: 1
    Last Post: 02-27-2009, 01:21 PM

Tags for this Thread

Posting Permissions

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