diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2011-12-13 11:51:39 +0000 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2011-12-13 11:51:39 +0000 |
commit | a5ef9a5f8b496787e7ca3f8510dea9d283105f25 (patch) | |
tree | 645b221fbaa4285901b4836cbe477ba8ddd5f645 | |
parent | 7ffae028567080b04e75c1f5ec8801da5c8106d0 (diff) | |
download | trackermap-server-a5ef9a5f8b496787e7ca3f8510dea9d283105f25.tar.gz trackermap-server-a5ef9a5f8b496787e7ca3f8510dea9d283105f25.tar.bz2 trackermap-server-a5ef9a5f8b496787e7ca3f8510dea9d283105f25.zip |
-rw-r--r-- | nbproject/project.properties | 4 | ||||
-rw-r--r-- | src/org/traccar/Server.java | 3 | ||||
-rw-r--r-- | src/org/traccar/helper/NamedParameterStatement.java | 21 |
3 files changed, 14 insertions, 14 deletions
diff --git a/nbproject/project.properties b/nbproject/project.properties index 8f2da5eb7..2a7d874ec 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -25,6 +25,7 @@ dist.jar=${dist.dir}/tracker-server.jar dist.javadoc.dir=${dist.dir}/javadoc
endorsed.classpath=
excludes=
+file.reference.jtds-1.2.5.jar=C:\\Test\\traccar\\jtds-1.2.5.jar
file.reference.netty-3.2.6.Final.jar=C:\\Test\\traccar\\lib\\netty-3.2.6.Final.jar
includes=**
jar.archive.disabled=${jnlp.enabled}
@@ -32,7 +33,8 @@ jar.compress=false jar.index=${jnlp.enabled}
javac.classpath=\
${libs.MySQLDriver.classpath}:\
- ${file.reference.netty-3.2.6.Final.jar}
+ ${file.reference.netty-3.2.6.Final.jar}:\
+ ${file.reference.jtds-1.2.5.jar}
# Space-separated list of extra javac options
javac.compilerargs=
javac.deprecation=false
diff --git a/src/org/traccar/Server.java b/src/org/traccar/Server.java index f2c5752f5..94e6f7ac3 100644 --- a/src/org/traccar/Server.java +++ b/src/org/traccar/Server.java @@ -142,6 +142,7 @@ public class Server implements DataManager { List deviceList = new LinkedList(); + selectDevice.prepare(); ResultSet result = selectDevice.executeQuery(); while (result.next()) { Device device = new Device(); @@ -168,6 +169,8 @@ public class Server implements DataManager { } public synchronized void setPosition(Position position) throws SQLException { + + insertPosition.prepare(); insertPosition.setLong("device_id", position.getDeviceId()); insertPosition.setTimestamp("time", position.getTime()); diff --git a/src/org/traccar/helper/NamedParameterStatement.java b/src/org/traccar/helper/NamedParameterStatement.java index bbb2bcdf3..5fbc57d78 100644 --- a/src/org/traccar/helper/NamedParameterStatement.java +++ b/src/org/traccar/helper/NamedParameterStatement.java @@ -114,11 +114,8 @@ public class NamedParameterStatement { return parsedQuery.toString(); } - - /** - * Execute query with result - */ - public ResultSet executeQuery() throws SQLException { + + public void prepare() throws SQLException { try { if (statement == null) { statement = connection.getInstance().prepareStatement(parsedQuery); @@ -127,6 +124,12 @@ public class NamedParameterStatement { connection.reset(); statement = connection.getInstance().prepareStatement(parsedQuery); } + } + + /** + * Execute query with result + */ + public ResultSet executeQuery() throws SQLException { return statement.executeQuery(); } @@ -135,14 +138,6 @@ public class NamedParameterStatement { * Executes query without result */ public int executeUpdate() throws SQLException { - try { - if (statement == null) { - statement = connection.getInstance().prepareStatement(parsedQuery); - } - } catch (SQLException error) { - connection.reset(); - statement = connection.getInstance().prepareStatement(parsedQuery); - } return statement.executeUpdate(); } |