Erster commit
This commit is contained in:
commit
0962ff3572
40
.classpath
Normal file
40
.classpath
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<classpath>
|
||||||
|
<classpathentry kind="src" output="target/classes" path="src/main/java">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="optional" value="true"/>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
<attribute name="optional" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="optional" value="true"/>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
<attribute name="test" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
<attribute name="test" value="true"/>
|
||||||
|
<attribute name="optional" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="output" path="target/classes"/>
|
||||||
|
</classpath>
|
||||||
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
/target/
|
||||||
23
.project
Normal file
23
.project
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>traccar-db-migrate</name>
|
||||||
|
<comment></comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
||||||
8
.settings/org.eclipse.jdt.core.prefs
Normal file
8
.settings/org.eclipse.jdt.core.prefs
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
eclipse.preferences.version=1
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=17
|
||||||
|
org.eclipse.jdt.core.compiler.compliance=17
|
||||||
|
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
||||||
|
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||||
|
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
|
||||||
|
org.eclipse.jdt.core.compiler.release=disabled
|
||||||
|
org.eclipse.jdt.core.compiler.source=17
|
||||||
4
.settings/org.eclipse.m2e.core.prefs
Normal file
4
.settings/org.eclipse.m2e.core.prefs
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
activeProfiles=
|
||||||
|
eclipse.preferences.version=1
|
||||||
|
resolveWorkspaceProjects=true
|
||||||
|
version=1
|
||||||
BIN
database.mv.db
Normal file
BIN
database.mv.db
Normal file
Binary file not shown.
40730
database.trace.db
Normal file
40730
database.trace.db
Normal file
File diff suppressed because it is too large
Load Diff
27
pom.xml
Normal file
27
pom.xml
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>info.peper.traccar</groupId>
|
||||||
|
<artifactId>traccar-db-migrate</artifactId>
|
||||||
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
|
</properties>
|
||||||
|
<dependencies>
|
||||||
|
<!-- https://mvnrepository.com/artifact/com.h2database/h2 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.h2database</groupId>
|
||||||
|
<artifactId>h2</artifactId>
|
||||||
|
<version>2.1.214</version>
|
||||||
|
</dependency>
|
||||||
|
<!--
|
||||||
|
https://mvnrepository.com/artifact/org.mariadb.jdbc/mariadb-java-client -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mariadb.jdbc</groupId>
|
||||||
|
<artifactId>mariadb-java-client</artifactId>
|
||||||
|
<version>3.4.1</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
||||||
64
src/main/java/info/peper/traccar/migrate/MigrateMain.java
Normal file
64
src/main/java/info/peper/traccar/migrate/MigrateMain.java
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
package info.peper.traccar.migrate;
|
||||||
|
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.DriverManager;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.Statement;
|
||||||
|
import java.sql.Types;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public class MigrateMain {
|
||||||
|
|
||||||
|
public static void main(String[] args) throws Exception {
|
||||||
|
// Class.forName ("org.h2.Driver");
|
||||||
|
final Connection conn = DriverManager.getConnection ("jdbc:h2:./database", "sa","");
|
||||||
|
final Statement stmt = conn.createStatement();
|
||||||
|
final Set<Integer> types = new HashSet<Integer>();
|
||||||
|
try (ResultSet rs = conn.getMetaData().getTables(null, null, null, null)) {
|
||||||
|
while (rs.next()) {
|
||||||
|
if (rs.getString("TABLE_SCHEM").equals("PUBLIC")) {
|
||||||
|
System.out.println(rs.getString("TABLE_SCHEM") + "\t" + rs.getString("TABLE_NAME") + "\t" + rs.getString("TABLE_TYPE"));
|
||||||
|
try (ResultSet rs2 = stmt.executeQuery("SELECT * FROM " + rs.getString("TABLE_NAME"))) {
|
||||||
|
for (int i = 0; i < rs2.getMetaData().getColumnCount(); i++) {
|
||||||
|
System.out.print("- " + rs2.getMetaData().getColumnName(i + 1) + "(" + rs2.getMetaData().getColumnType(i + 1) + ") ");
|
||||||
|
types.add(rs2.getMetaData().getColumnType(i + 1));
|
||||||
|
}
|
||||||
|
System.out.println();
|
||||||
|
while (rs2.next()) {
|
||||||
|
// for (int i = 0; i < rs2.getMetaData().getColumnCount(); i++) {
|
||||||
|
// System.out.print("- " + rs2.getString(rs2.getMetaData().getColumnName(i + 1)));
|
||||||
|
// }
|
||||||
|
System.out.print(".");
|
||||||
|
}
|
||||||
|
System.out.println();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* 16 BOOLEAN
|
||||||
|
* 1 CHAR
|
||||||
|
* 4 INTEGER
|
||||||
|
* 2004 BLOB
|
||||||
|
* 6 FLOAT
|
||||||
|
* 8 DOUBLE
|
||||||
|
* 12 VARCHAR
|
||||||
|
* 93 TIMESTAMP
|
||||||
|
*/
|
||||||
|
System.out.println(types.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* TABLE_CAT String => table catalog (may be null)
|
||||||
|
TABLE_SCHEM String => table schema (may be null)
|
||||||
|
TABLE_NAME String => table name
|
||||||
|
TABLE_TYPE String => table type. Typical types are "TABLE", "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY", "LOCAL TEMPORARY", "ALIAS", "SYNONYM".
|
||||||
|
REMARKS String => explanatory comment on the table (may be null)
|
||||||
|
TYPE_CAT String => the types catalog (may be null)
|
||||||
|
TYPE_SCHEM String => the types schema (may be null)
|
||||||
|
TYPE_NAME String => type name (may be null)
|
||||||
|
SELF_REFERENCING_COL_NAME String => name of the designated "identifier" column of a typed table (may be null)
|
||||||
|
REF_GENERATION String => specifies how values in SELF_REFERENCING_COL_NAME are created. Values are "SYSTEM", "USER", "DERIVED". (may be null)
|
||||||
|
*/
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user