00001 import java.io.File;
00002 import java.io.PrintStream;
00003 import java.sql.Connection;
00004 import java.sql.DriverManager;
00005 import java.sql.ResultSet;
00006 import java.sql.Statement;
00007
00008 import edu.tum.cs.srldb.Database;
00009 import edu.tum.cs.srldb.Object;
00010 import edu.tum.cs.srldb.datadict.DataDictionary;
00011
00012
00013 public class AtomicMLNTest {
00014 public static void main(String[] args) {
00015 try {
00016 System.out.println("fetching data...");
00017
00018
00019 Class.forName("com.mysql.jdbc.Driver").newInstance();
00020
00021
00022 Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/test?user=Dominik&password=nirvana");
00023
00024
00025 Statement stmt = conn.createStatement();
00026 ResultSet rs = stmt.executeQuery("SELECT if(A=1,'true','false') as A, if(B=1,'true','false') as B FROM dectree");
00027
00028
00029 Database database = new Database(new DataDictionary());
00030 while(rs.next()) {
00031
00032
00033 Object obj = new Object(database, "object");
00034 obj.addAttribsFromResultSet(rs, false);
00035
00036 }
00037
00038
00039 System.out.println("writing MLN database...");
00040
00041 PrintStream out = new PrintStream(new File("mln/atomic_events/data.db"));
00042 database.writeMLNDatabase(out);
00043 }
00044 catch(Exception e) {
00045 e.printStackTrace();
00046 }
00047 }
00048 }