summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2008-04-07 08:22:45 (EDT)
committerEike Stepper2008-04-07 08:22:45 (EDT)
commit102e6770982f5374b1099d2a76fc814163de8917 (patch)
tree6292ea681628fdc2d568a12d93f8e0c93b6ae6db
parentdf04525b9d0b58c0e82f59ee6a6749646bf16dd0 (diff)
downloadcdo-102e6770982f5374b1099d2a76fc814163de8917.zip
cdo-102e6770982f5374b1099d2a76fc814163de8917.tar.gz
cdo-102e6770982f5374b1099d2a76fc814163de8917.tar.bz2
[214487] Use prepared statements if appropriate
https://bugs.eclipse.org/bugs/show_bug.cgi?id=214487
-rw-r--r--plugins/org.eclipse.net4j.db.hsqldb/src/org/eclipse/net4j/db/internal/hsqldb/HSQLDBAdapter.java14
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBType.java27
-rw-r--r--plugins/org.eclipse.net4j.jms.server.jdbc/src/org/eclipse/net4j/jms/server/jdbc/JDBCUtil.java2
3 files changed, 38 insertions, 5 deletions
diff --git a/plugins/org.eclipse.net4j.db.hsqldb/src/org/eclipse/net4j/db/internal/hsqldb/HSQLDBAdapter.java b/plugins/org.eclipse.net4j.db.hsqldb/src/org/eclipse/net4j/db/internal/hsqldb/HSQLDBAdapter.java
index fc717c7..2e37e52 100644
--- a/plugins/org.eclipse.net4j.db.hsqldb/src/org/eclipse/net4j/db/internal/hsqldb/HSQLDBAdapter.java
+++ b/plugins/org.eclipse.net4j.db.hsqldb/src/org/eclipse/net4j/db/internal/hsqldb/HSQLDBAdapter.java
@@ -15,6 +15,9 @@ import org.eclipse.net4j.internal.db.DBAdapter;
import org.eclipse.net4j.internal.db.ddl.DBField;
import org.hsqldb.jdbcDriver;
+import org.hsqldb.jdbc.jdbcDataSource;
+
+import javax.sql.DataSource;
import java.sql.Driver;
@@ -23,9 +26,13 @@ import java.sql.Driver;
*/
public class HSQLDBAdapter extends DBAdapter
{
+ private static final String NAME = "hsqldb";
+
+ public static final String VERSION = "1.8.0.8";
+
public HSQLDBAdapter()
{
- super("hsqldb", "1.8.0.8");
+ super(NAME, VERSION);
}
public Driver getJDBCDriver()
@@ -33,6 +40,11 @@ public class HSQLDBAdapter extends DBAdapter
return new jdbcDriver();
}
+ public DataSource createJDBCDataSource()
+ {
+ return new jdbcDataSource();
+ }
+
@Override
protected String getTypeName(DBField field)
{
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBType.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBType.java
index 686db7f..81f1d9c 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBType.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBType.java
@@ -114,14 +114,35 @@ public enum DBType
{
if (value instanceof String || value instanceof Character)
{
+ builder.append("'");
if (value instanceof String)
{
- value = ((String)value).replaceAll("'", "\\'");
+ /*
+ * Stefan Winkler <stefan.winkler-et@fernuni-hagen.de> 2008-04-01 (no April's joke!) changed \\' to \\\\'
+ * because at least with MySQL \\' is not enough for some reason - the \\ get eaten up somewhere on the way
+ * :-(
+ */
+
+ String str = (String)value;
+ for (int i = 0; i < str.length(); i++)
+ {
+ char c = str.charAt(i);
+ if (c == '\'')
+ {
+ builder.append("\\\'");
+ }
+ else
+ {
+ builder.append(c);
+ }
+ }
+ }
+ else
+ {
+ builder.append(value);
}
builder.append("'");
- builder.append(value);
- builder.append("'");
}
else
{
diff --git a/plugins/org.eclipse.net4j.jms.server.jdbc/src/org/eclipse/net4j/jms/server/jdbc/JDBCUtil.java b/plugins/org.eclipse.net4j.jms.server.jdbc/src/org/eclipse/net4j/jms/server/jdbc/JDBCUtil.java
index 489604f..9cd6f0a 100644
--- a/plugins/org.eclipse.net4j.jms.server.jdbc/src/org/eclipse/net4j/jms/server/jdbc/JDBCUtil.java
+++ b/plugins/org.eclipse.net4j.jms.server.jdbc/src/org/eclipse/net4j/jms/server/jdbc/JDBCUtil.java
@@ -39,7 +39,7 @@ public final class JDBCUtil
public static IStore getStore()
{
Properties properties = OM.BUNDLE.getConfigProperties();
- String adapterName = properties.getProperty("store.adapterName", "derby");
+ String adapterName = properties.getProperty("store.adapterName", "derby-embedded");
IDBAdapter dbAdapter = DBUtil.getDBAdapter(adapterName);
DataSource dataSource = DBUtil.createDataSource(properties, "datasource");
String instanceID = properties.getProperty("store.instanceID", "00000000");