0

I have a problem with this for a while. Importing data from TEXT field into textArea make no problem for me (even if it's longer than String), but I have no idea how to make it work opposite way. (Using sqlite) My code to get data from db:

Statement myStmt = con.createStatement();
ResultSet myRs = myStmt.executeQuery("SELECT * from test");

while(myRs.next())
{
    if(myRs.getInt("Id_przepisu") == przepis.getId_przepisu() )
    {   
        textArea.setText(myRs.getString("text"));
    }
}

myStmt.close();
myRs.close();

code to save data in db

insert = con.prepareStatement
( "INSERT INTO test (Id_przepisu, text)   VALUES ('"+przepis.getId_przepisu()+"','"+
textArea.getText()+"')"); 
insert.executeUpdate();
Hazeltrap
  • 31
  • 4
  • https://stackoverflow.com/questions/24661919/bigger-data-type-than-string 8 encyclopedias in a textarea?? – Carl Shiles Jun 19 '17 at 15:19
  • Aside: Use a prepared statement properly. Someone could do SQL injection in what you currently have. Also, I highly doubt you will ever hit the capacity of String from handwritten text. – Compass Jun 19 '17 at 15:19

1 Answers1

0

You might find a good answer and workaround for you problem here: https://stackoverflow.com/a/17785119/575643

In short, if is bigger than the TEXT type you would need to split it manually. Search for substring, it would help.

Idemax
  • 2,712
  • 6
  • 33
  • 66