Merge branch 'Cached-Client'
						commit
						67b01032d0
					
				| 
						 | 
					@ -51,6 +51,7 @@ dependencies {
 | 
				
			||||||
    compile 'org.xerial:sqlite-jdbc:3.8.+'
 | 
					    compile 'org.xerial:sqlite-jdbc:3.8.+'
 | 
				
			||||||
    compile 'mysql:mysql-connector-java:5.1.+'
 | 
					    compile 'mysql:mysql-connector-java:5.1.+'
 | 
				
			||||||
    compile 'com.h2database:h2:1.0.+'
 | 
					    compile 'com.h2database:h2:1.0.+'
 | 
				
			||||||
 | 
					    compile 'org.apache.commons:commons-dbcp2:2.0.+'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Servlets
 | 
					    // Servlets
 | 
				
			||||||
    compile 'javax.servlet:javax.servlet-api:3.0.+'
 | 
					    compile 'javax.servlet:javax.servlet-api:3.0.+'
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,6 +1,7 @@
 | 
				
			||||||
package meerkat.bulletinboard.sqlserver;
 | 
					package meerkat.bulletinboard.sqlserver;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import meerkat.protobuf.BulletinBoardAPI.FilterType;
 | 
					import meerkat.protobuf.BulletinBoardAPI.FilterType;
 | 
				
			||||||
 | 
					import org.apache.commons.dbcp2.BasicDataSource;
 | 
				
			||||||
import org.h2.jdbcx.JdbcDataSource;
 | 
					import org.h2.jdbcx.JdbcDataSource;
 | 
				
			||||||
import javax.naming.Context;
 | 
					import javax.naming.Context;
 | 
				
			||||||
import javax.naming.InitialContext;
 | 
					import javax.naming.InitialContext;
 | 
				
			||||||
| 
						 | 
					@ -61,7 +62,7 @@ public class H2QueryProvider implements BulletinBoardSQLServer.SQLQueryProvider
 | 
				
			||||||
                return "SELECT Signature FROM SignatureTable WHERE EntryNum = :EntryNum";
 | 
					                return "SELECT Signature FROM SignatureTable WHERE EntryNum = :EntryNum";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            case INSERT_MSG:
 | 
					            case INSERT_MSG:
 | 
				
			||||||
                return "INSERT INTO MsgTable (MsgId, Msg) VALUES(:MsgId,:Msg)";
 | 
					                return "INSERT INTO MsgTable (MsgId, Msg, ExactTime) VALUES(:MsgId,:Msg,:TimeStamp)";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            case INSERT_NEW_TAG:
 | 
					            case INSERT_NEW_TAG:
 | 
				
			||||||
                return "INSERT INTO TagTable(Tag) SELECT DISTINCT :Tag AS NewTag FROM UtilityTable WHERE"
 | 
					                return "INSERT INTO TagTable(Tag) SELECT DISTINCT :Tag AS NewTag FROM UtilityTable WHERE"
 | 
				
			||||||
| 
						 | 
					@ -200,10 +201,13 @@ public class H2QueryProvider implements BulletinBoardSQLServer.SQLQueryProvider
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public DataSource getDataSource() {
 | 
					    public DataSource getDataSource() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        JdbcDataSource dataSource = new JdbcDataSource();
 | 
					        BasicDataSource dataSource = new BasicDataSource();
 | 
				
			||||||
        dataSource.setURL("jdbc:h2:~/" + dbName);
 | 
					
 | 
				
			||||||
 | 
					        dataSource.setDriverClassName("org.h2.Driver");
 | 
				
			||||||
 | 
					        dataSource.setUrl("jdbc:h2:~/" + dbName);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return dataSource;
 | 
					        return dataSource;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -4,6 +4,7 @@ import com.mysql.jdbc.jdbc2.optional.MysqlDataSource;
 | 
				
			||||||
import meerkat.bulletinboard.BulletinBoardConstants;
 | 
					import meerkat.bulletinboard.BulletinBoardConstants;
 | 
				
			||||||
import meerkat.bulletinboard.sqlserver.BulletinBoardSQLServer.SQLQueryProvider;
 | 
					import meerkat.bulletinboard.sqlserver.BulletinBoardSQLServer.SQLQueryProvider;
 | 
				
			||||||
import meerkat.protobuf.BulletinBoardAPI.FilterType;
 | 
					import meerkat.protobuf.BulletinBoardAPI.FilterType;
 | 
				
			||||||
 | 
					import org.apache.commons.dbcp2.BasicDataSource;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import javax.sql.DataSource;
 | 
					import javax.sql.DataSource;
 | 
				
			||||||
import java.text.MessageFormat;
 | 
					import java.text.MessageFormat;
 | 
				
			||||||
| 
						 | 
					@ -216,16 +217,17 @@ public class MySQLQueryProvider implements SQLQueryProvider {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public DataSource getDataSource() {
 | 
					    public DataSource getDataSource() {
 | 
				
			||||||
        MysqlDataSource dataSource = new MysqlDataSource();
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        dataSource.setServerName(dbAddress);
 | 
					        BasicDataSource dataSource = new BasicDataSource();
 | 
				
			||||||
        dataSource.setPort(dbPort);
 | 
					
 | 
				
			||||||
        dataSource.setDatabaseName(dbName);
 | 
					        dataSource.setDriverClassName("com.mysql.jdbc.Driver");
 | 
				
			||||||
        dataSource.setUser(username);
 | 
					        dataSource.setUrl("jdbc:mysql://" + dbAddress + ":" + dbPort + "/" + dbName);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        dataSource.setUsername(username);
 | 
				
			||||||
        dataSource.setPassword(password);
 | 
					        dataSource.setPassword(password);
 | 
				
			||||||
        dataSource.setAllowMultiQueries(true);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return dataSource;
 | 
					        return dataSource;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -140,6 +140,16 @@ public class H2BulletinBoardServerTest {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Test
 | 
				
			||||||
 | 
					    public void testSyncQuery() {
 | 
				
			||||||
 | 
					        try {
 | 
				
			||||||
 | 
					            serverTest.testSyncQuery();
 | 
				
			||||||
 | 
					        } catch (Exception e) {
 | 
				
			||||||
 | 
					            System.err.println(e.getMessage());
 | 
				
			||||||
 | 
					            fail(e.getMessage());
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @After
 | 
					    @After
 | 
				
			||||||
    public void close() {
 | 
					    public void close() {
 | 
				
			||||||
        System.err.println("Starting to close H2BulletinBoardServerTest");
 | 
					        System.err.println("Starting to close H2BulletinBoardServerTest");
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue