Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: problem - insert negative value to mysql database.

  1. #1
    Junior Member vasanthjayaraman's Avatar
    Join Date
    Jul 2013
    Location
    Chennai
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default problem - insert negative value to mysql database.

    Hi Friends,
    In my project, i want to update excel values to the database....but my database did not get negative values...please any one help me...how to insert negative values to database.............

    >>>>Thanks and Regards

    Vasanth Jayaraman


  2. #2
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 167 Times in 158 Posts

    Default Re: problem - insert negative value to mysql database.

    Change your code!
    Improving the world one idiot at a time!

  3. #3
    Junior Member vasanthjayaraman's Avatar
    Join Date
    Jul 2013
    Location
    Chennai
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: problem - insert negative value to mysql database.

    Thanks for your Response....

    this is my excel sheet img


    my code

     for(int i=1; i<=sheet.getLastRowNum(); i++){  
    	                row = sheet.getRow(i);  
    				//	int id=0;
    	                int time = (int) row.getCell(0).getNumericCellValue();  
    					int xaxis = (int) row.getCell(1).getNumericCellValue(); 
    					int yaxis = (int) row.getCell(2).getNumericCellValue(); 
    					int zaxis = (int) row.getCell(3).getNumericCellValue(); 
    	             //   String name = row.getCell(1).getStringCellValue();  
    	             //   String salary = row.getCell(2).getStringCellValue();  
    	             //   String sql = "INSERT INTO datas VALUES('"+id+"','"+name+"','"+salary+"')";  
    				 String sql = "INSERT INTO datas VALUES('"+time+"','"+xaxis+"','"+yaxis+"','"+zaxis+"')";  
    	                pstm = (PreparedStatement) con.prepareStatement(sql);  
    	                pstm.execute();

    and my output like

  4. #4
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: problem - insert negative value to mysql database.

    but my database did not get negative values
    What do you mean by this? Do you mean when you try to insert a negative value into a column, it is non-negative after insertion? Is the column the correct data type to store negative values (eg, is it signed or unsigned?)

Similar Threads

  1. Problem on backup Mysql database to another computer
    By Uncanny Heart in forum JDBC & Databases
    Replies: 1
    Last Post: September 30th, 2012, 11:30 AM
  2. Replies: 1
    Last Post: June 29th, 2012, 01:29 PM
  3. How to insert date in database
    By AJAXx195 in forum JDBC & Databases
    Replies: 1
    Last Post: January 24th, 2012, 03:26 PM
  4. [SOLVED] Using Java CheckBox to insert data to MSAccess Database
    By sandlucky in forum JDBC & Databases
    Replies: 1
    Last Post: May 15th, 2011, 11:43 PM
  5. Insert into database from flat file
    By HelloAll in forum JDBC & Databases
    Replies: 2
    Last Post: March 10th, 2011, 11:05 PM