title: Inserting an SQL query string into an SQL table
body: <p>I want to insert an SQL query string into my database, but I always get an error because of the single quotes <code>''</code>. I can't just double them <code>''''</code>, because then I can't execute the SQL query which is stored in the SQL database. Here is an example:</p>
  
  <pre><code>"INSERT INTO selections(selection_name, selection_sql, selection_besitzer, selection_sichtbarkeit, selection_standardSelektion)"
              + "VALUES ('"
              + "TestName"+"', '"
              + "Select * From customer where customer_adressnummer like '%1%';"+"', '"
              + "Select all from customer where X"+"', '"
              + "private"+"', '"
              + "0"+"')");
  </code></pre>
  
  <p>My question is: How can I insert this query into my SQL database without changing the String?</p>
  
  <p>After I insert it I want to read it with my program and then execute the query based on the String in my database.</p>
  
  <p>Here's the error message:</p>
  
  <pre><code>com.mysql.jdbc.MysqlDataTruncation: Data truncation: Truncated incorrect DOUBLE value: 'Select * From customer where customer_adressnummer like '
      at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3374)
      at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3308)
      at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1837)
      at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1961)
      at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2543)
      at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1737)
      at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2022)
      at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1940)
      at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1925)
      at toolhouseserver.ExecutionThread.run(ExecutionThread.java:114)
      at java.lang.Thread.run(Thread.java:745)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      at java.lang.Thread.run(Thread.java:745)
  </code></pre>