Created
November 20, 2012 19:56
-
-
Save krummas/4120613 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
public void doQuery() throws SQLException{ | |
Connection conn = DriverManager.getConnection("jdbc:mysql:thin://root@localhost:3306/sampledb"); | |
String querybeforeCheck = "select Table1.* , Table2.code , Table2.Instruction , Table3.sName , Table3.LineNumber ,Table3.sFName , Table4.TData , Table4.TDataUpdated from Table1 LEFT JOIN Table4 on (Table1.Id = Table4.Id) LEFT JOIN Table2 on (Table1.Address = Table2.Address) LEFT JOIN Table3 on (Table1.Address = Table3.Address)where Table1.id > -1 ORDER BY Table1.id ASC LIMIT 1500"; | |
Statement statement = conn.createStatement( | |
ResultSet.TYPE_SCROLL_INSENSITIVE, | |
ResultSet.CONCUR_UPDATABLE); | |
ResultSet result = statement.executeQuery(querybeforeCheck); | |
while (!result.isClosed() && result.next()) { | |
if (null != result && !result.isClosed()) { | |
// System.out.println(result.getString("Instruction")); | |
} | |
} | |
String queryafterCheck = "select Table4.Id, \n" + | |
" Table4.PData, \n" + | |
" Table4.TData, \n" + | |
" Table4.TDataUpdated, \n" + | |
" Table1.*, \n" + | |
" Table2.code, \n" + | |
" Table2.Instruction, \n" + | |
" Table3.sname, \n" + | |
" Table3.LineNumber, \n" + | |
" Table3.sFName \n" + | |
"from Table4 left join Table1 on ( Table1.Id = Table4.id) \n" + | |
" LEFT JOIN Table2 on (Table1.Address = Table2.Address) \n" + | |
" LEFT JOIN Table3 on (Table1.Address = Table3.Address) \n" + | |
"where Table4.Id > -1 ORDER BY Table4.Id ASC LIMIT 1500"; | |
statement = conn.createStatement( | |
ResultSet.TYPE_SCROLL_INSENSITIVE, | |
ResultSet.CONCUR_UPDATABLE); | |
result = statement.executeQuery(queryafterCheck); | |
while (!result.isClosed() && result.next()) { | |
if (null != result && !result.isClosed()) { | |
long table4Id = result.getLong("Id"); | |
long table1Id = result.getLong("Table1Id"); | |
long tData = result.getLong("TData"); | |
int pData = result.getInt("PData"); | |
int table4_tDataUpdated = result.getInt("Table4.TDataUpdated"); | |
int table1_tDataUpdated = result.getInt("Table1.TDataUpdated"); | |
long t1Address = result.getLong("Address"); | |
long data = result.getLong("Data"); | |
//int dataAttribute = result.getInt(ITable1.DATA_ATRIBUTE); | |
long noCycles = result.getLong("CycleInfo"); | |
long code = result.getLong("code"); | |
String instruction = result.getString("Instruction"); | |
String sName = result.getString("sname"); | |
String sFName = result.getString("sfname"); | |
int lineNumber = result.getInt("LineNumber"); | |
System.out.println(tData); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment