Skip to content

Commit

Permalink
[CONJ-201] prepareStatement with second part correction.
Browse files Browse the repository at this point in the history
  • Loading branch information
rusher committed Oct 5, 2015
1 parent 4c8a002 commit f27820c
Show file tree
Hide file tree
Showing 22 changed files with 187 additions and 300 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -21,7 +21,7 @@ or maven :
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>1.2.2</version>
<version>1.2.3</version>
</dependency>
```

Expand Down
51 changes: 39 additions & 12 deletions pom.xml
@@ -1,39 +1,46 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<packaging>jar</packaging>
<name>mariadb-java-client</name>
<version>1.3.0-SNAPSHOT</version>
<version>1.2.3</version>
<description>JDBC driver for MariaDB and MySQL</description>
<url>https://mariadb.com/kb/en/mariadb/about-mariadb-connector-j/</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jna.version>3.3.0</jna.version>
<version.template.file>src/main/resources/Version.java.template</version.template.file>
<version.file>src/main/java/org/mariadb/jdbc/Version.java</version.file>
</properties>

<licenses>
<license>
<name>LGPL-2.1</name>
</license>
</licenses>

<scm>
<connection>scm:git:git://github.com/MariaDB/mariadb-connector-j.git</connection>
<url>https://github.com/MariaDB/mariadb-connector-j</url>
<developerConnection>scm:git:git@github.com:MariaDB/mariadb-connector-j.git</developerConnection>
</scm>

<issueManagement>
<system>JIRA</system>
<url>https://mariadb.atlassian.net/browse/CONJ</url>
</issueManagement>

<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>

<developers>
<developer>
<id>wlad</id>
Expand All @@ -56,6 +63,7 @@
<email>diego.dupin@mariadb.com</email>
</developer>
</developers>

<profiles>
<profile>
<id>test</id>
Expand All @@ -67,7 +75,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12.4</version>
<version>2.18.1</version>
<configuration>
<argLine>-Xmx1g</argLine>
<systemProperties>
Expand Down Expand Up @@ -134,13 +142,6 @@
</arguments>
</configuration>
</plugin>
<!--<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
Expand Down Expand Up @@ -209,6 +210,31 @@
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<!--<plugin>-->
<!--<groupId>org.apache.maven.plugins</groupId>-->
<!--<artifactId>maven-javadoc-plugin</artifactId>-->
<!--<version>2.10.3</version>-->
<!--<executions>-->
<!--<execution>-->
<!--<id>attach-javadocs</id>-->
<!--<goals>-->
<!--<goal>jar</goal>-->
<!--</goals>-->
<!--</execution>-->
<!--</executions>-->
<!--</plugin>-->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
Expand All @@ -224,8 +250,8 @@
</plugin>
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>maven-replacer-plugin</artifactId>
<version>1.4.1</version>
<artifactId>replacer</artifactId>
<version>1.5.3</version>
<executions>
<execution>
<phase>process-sources</phase>
Expand Down Expand Up @@ -285,6 +311,7 @@
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.java.dev.jna</groupId>
Expand Down Expand Up @@ -317,6 +344,6 @@
<parent>
<groupId>org.sonatype.oss</groupId>
<artifactId>oss-parent</artifactId>
<version>6</version>
<version>9</version>
</parent>
</project>
7 changes: 0 additions & 7 deletions src/main/java/org/mariadb/jdbc/Driver.java
Expand Up @@ -53,10 +53,6 @@ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWIS
import org.mariadb.jdbc.internal.common.QueryException;
import org.mariadb.jdbc.internal.common.Utils;
import org.mariadb.jdbc.internal.mysql.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.lang.reflect.Proxy;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.DriverPropertyInfo;
Expand All @@ -68,7 +64,6 @@ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWIS


public final class Driver implements java.sql.Driver {
private final static Logger log = LoggerFactory.getLogger(Driver.class);

static {
try {
Expand All @@ -89,13 +84,11 @@ public final class Driver implements java.sql.Driver {
*/
public Connection connect(final String url, final Properties props) throws SQLException {

log.debug("Connecting to: " + url);
try {
JDBCUrl jdbcUrl = JDBCUrl.parse(url, props);
//
if (jdbcUrl == null) return null;
if (jdbcUrl.getHostAddresses() == null) {
log.info("MariaDB connector : missing Host address");
return null;
} else {
ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
Expand Down
3 changes: 0 additions & 3 deletions src/main/java/org/mariadb/jdbc/MySQLDataSource.java
Expand Up @@ -56,7 +56,6 @@ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWIS
import org.mariadb.jdbc.internal.common.UrlHAMode;
import org.mariadb.jdbc.internal.common.Utils;
import org.mariadb.jdbc.internal.mysql.*;
import org.slf4j.LoggerFactory;

import javax.sql.*;

Expand All @@ -72,7 +71,6 @@ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWIS


public class MySQLDataSource implements DataSource, ConnectionPoolDataSource, XADataSource {
private final static org.slf4j.Logger log = LoggerFactory.getLogger(MySQLDataSource.class);

private final JDBCUrl jdbcUrl;

Expand Down Expand Up @@ -281,7 +279,6 @@ public Connection getConnection() throws SQLException {
public Connection getConnection(final String username, final String password) throws SQLException {
jdbcUrl.setUsername(username);
jdbcUrl.setPassword(password);
if (log.isDebugEnabled()) log.debug("connection : " +jdbcUrl.toString());
return getConnection();
}

Expand Down
6 changes: 0 additions & 6 deletions src/main/java/org/mariadb/jdbc/MySQLPreparedStatement.java
Expand Up @@ -52,8 +52,6 @@ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWIS
import org.mariadb.jdbc.internal.common.Utils;
import org.mariadb.jdbc.internal.common.query.*;
import org.mariadb.jdbc.internal.common.query.parameters.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.io.InputStream;
Expand All @@ -69,7 +67,6 @@ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWIS


public class MySQLPreparedStatement extends MySQLStatement implements PreparedStatement {
private final static Logger log = LoggerFactory.getLogger(MySQLPreparedStatement.class);
private MySQLParameterizedQuery dQuery;
private String sql;
private boolean useFractionalSeconds;
Expand All @@ -82,9 +79,6 @@ public MySQLPreparedStatement(MySQLConnection connection,
this.sql = sql;
useFractionalSeconds =
connection.getProtocol().getOptions().useFractionalSeconds;
if(log.isDebugEnabled()) {
log.debug("Creating prepared statement for " + sql);
}
isInsertRewriteable(sql);
dQuery = new MySQLParameterizedQuery(Utils.nativeSQL(sql, connection.noBackslashEscapes),
connection.noBackslashEscapes, isRewriteable?firstRewrite.length():-1);
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/org/mariadb/jdbc/Version.java
@@ -1,10 +1,10 @@
package org.mariadb.jdbc;

public final class Version {
public static final String version = "1.3.0-SNAPSHOT";
public static final String version = "1.2.3";
public static final int majorVersion = 1;
public static final int minorVersion = 3;
public static final int patchVersion = 0;
public static final String qualifier = "SNAPSHOT";
public static final int minorVersion = 2;
public static final int patchVersion = 3;
public static final String qualifier = "";

}
@@ -1,15 +1,11 @@
package org.mariadb.jdbc.internal.common.packet;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;


public class PacketOutputStream extends OutputStream {
private final static Logger log = LoggerFactory.getLogger(PacketOutputStream.class);

private static final int MAX_PACKET_LENGTH = 0x00ffffff;
private static final int SEQNO_OFFSET = 3;
Expand Down Expand Up @@ -132,12 +128,6 @@ private void internalFlush() throws IOException {
throw new MaxAllowedPacketException("max_allowed_packet exceeded. wrote " + bytesWritten + ", max_allowed_packet = " +maxAllowedPacket, this.seqNo != 0);
}
baseStream.write(byteBuffer, 0, position);
if (log.isTraceEnabled()) {
byte[] tmp = new byte[Math.min(1000, position)];
System.arraycopy(byteBuffer, 0, tmp, 0, Math.min(1000, position));
log.trace(new String(tmp));
}

position = HEADER_LENGTH;
this.seqNo++;
}
Expand Down
Expand Up @@ -73,31 +73,29 @@ public StreamedQueryPacket(final List<Query> queries, boolean isRewritable, int
}

public int send(final OutputStream ostream) throws IOException, QueryException {
PacketOutputStream pos = (PacketOutputStream) ostream;
pos.startPacket(0);
pos.write(0x03);

if (queries.size() == 1) {
PacketOutputStream pos = (PacketOutputStream)ostream;
pos.startPacket(0);
pos.write(0x03);
queries.get(0).writeTo(ostream);
pos.finishPacket();
} else {
PacketOutputStream pos = (PacketOutputStream)ostream;
pos.startPacket(0);
pos.write(0x03);
if (!isRewritable) {
queries.get(0).writeTo(ostream);
for (int i=1;i<queries.size();i++) {
for (int i = 1; i < queries.size(); i++) {
pos.write(';');
queries.get(i).writeTo(ostream);
}
} else {
queries.get(0).writeFirstRewritePart(ostream);
for (int i = 1;i<queries.size();i++) {
queries.get(i).writeToRewritablePart(ostream, rewriteOffset);
for (int i = 1; i < queries.size(); i++) {
queries.get(i).writeToRewritablePart(ostream, rewriteOffset);
}
queries.get(0).writeLastRewritePart(ostream);
}
pos.finishPacket();
}

pos.finishPacket();
return 0;
}

Expand Down

0 comments on commit f27820c

Please sign in to comment.