Compare commits
No commits in common. "master" and "testread" have entirely different histories.
@ -26,8 +26,6 @@ dependencies {
|
||||
//jdbc drivers
|
||||
implementation 'org.postgresql:postgresql:42.5.0'
|
||||
implementation 'net.sf.jt400:jt400:11.0'
|
||||
implementation 'com.microsoft.sqlserver:mssql-jdbc:9.2.0.jre8'
|
||||
implementation 'com.microsoft.sqlserver:mssql-jdbc_auth:9.2.0.x64'
|
||||
}
|
||||
|
||||
application {
|
||||
|
@ -4,7 +4,6 @@ import java.util.*;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path ;
|
||||
import java.nio.file.Paths;
|
||||
import java.time.*;
|
||||
|
||||
public class jrunner {
|
||||
//static final String QUERY = "SELECT * from rlarp.osm LIMIT 100";
|
||||
@ -20,7 +19,6 @@ public class jrunner {
|
||||
String sq = "";
|
||||
String dt = "";
|
||||
Boolean trim = true;
|
||||
Boolean clear = true;
|
||||
Integer r = 0;
|
||||
Integer t = 0;
|
||||
String sql = "";
|
||||
@ -36,10 +34,8 @@ public class jrunner {
|
||||
String[] getv = null;
|
||||
Integer cols = null;
|
||||
String[] dtn = null;
|
||||
Timestamp tsStart = null;
|
||||
Timestamp tsEnd = null;
|
||||
|
||||
msg = "jrunner version 0.41";
|
||||
msg = "jrunner version 0.35";
|
||||
msg = msg + nl + "-scu source jdbc url";
|
||||
msg = msg + nl + "-scn source username";
|
||||
msg = msg + nl + "-scp source passowrd";
|
||||
@ -49,7 +45,6 @@ public class jrunner {
|
||||
msg = msg + nl + "-sq path to source query";
|
||||
msg = msg + nl + "-dt fully qualified name of destination table";
|
||||
msg = msg + nl + "-t trim text";
|
||||
msg = msg + nl + "-c clear target table";
|
||||
msg = msg + nl + "--help info";
|
||||
|
||||
//---------------------------------------parse args into variables-------------------------------------------------
|
||||
@ -65,7 +60,6 @@ public class jrunner {
|
||||
scn = args[i+1];
|
||||
break;
|
||||
//source password
|
||||
//import java.time.*;
|
||||
case "-scp":
|
||||
scp = args[i+1];
|
||||
break;
|
||||
@ -101,9 +95,6 @@ public class jrunner {
|
||||
case "-t":
|
||||
trim = true;
|
||||
break;
|
||||
case "-c":
|
||||
clear = true;
|
||||
break;
|
||||
case "-v":
|
||||
System.out.println(msg);
|
||||
return;
|
||||
@ -170,9 +161,6 @@ public class jrunner {
|
||||
//----------------------------------------open resultset------------------------------------------------------------
|
||||
try {
|
||||
stmt = scon.createStatement();
|
||||
stmt.setFetchSize(10000);
|
||||
tsStart = Timestamp.from(Instant.now());
|
||||
System.out.println(tsStart);
|
||||
rs = stmt.executeQuery(sq);
|
||||
//while (rs.next()) {
|
||||
// System.out.println(rs.getString("x"));
|
||||
@ -203,67 +191,39 @@ public class jrunner {
|
||||
e.printStackTrace();
|
||||
System.exit(0);
|
||||
}
|
||||
//-------------------------clear the target table if requeted----------------------------------------------------
|
||||
if (clear) {
|
||||
System.out.println("------------clear target table----------------------------");
|
||||
sql = "DELETE FROM " + dt;
|
||||
try {
|
||||
stmtd = dcon.createStatement();
|
||||
System.out.println(" " + sql);
|
||||
stmtd.executeUpdate(sql);
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
System.out.println(sql);
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
System.out.println("------------row count-------------------------------------");
|
||||
//-------------------------------build & execute sql-------------------------------------------------------------
|
||||
try {
|
||||
sql = "";
|
||||
while (rs.next()) {
|
||||
r++;
|
||||
t++;
|
||||
nr = "";
|
||||
for (int i = 1; i <= cols; i++){
|
||||
switch (dtn[i].toUpperCase()){
|
||||
switch (dtn[i]){
|
||||
case "VARCHAR":
|
||||
nc = rs.getString(i);
|
||||
nc = rs.getString(i).replace("'","''");
|
||||
if (rs.wasNull() || nc == null) {
|
||||
nc = "NULL";
|
||||
break;
|
||||
}
|
||||
nc = nc.replaceAll("'","''");
|
||||
if (trim) { nc = nc.trim();}
|
||||
nc = "'" + nc + "'";
|
||||
break;
|
||||
case "TEXT":
|
||||
nc = rs.getString(i);
|
||||
if (rs.wasNull() || nc == null) {
|
||||
nc = "NULL";
|
||||
break;
|
||||
}
|
||||
nc = nc.replaceAll("'","''");
|
||||
if (trim) { nc = nc.trim();}
|
||||
nc = "'" + nc + "'";
|
||||
break;
|
||||
case "CHAR":
|
||||
nc = rs.getString(i);
|
||||
if (rs.wasNull() || nc == null) {
|
||||
nc = "NULL";
|
||||
break;
|
||||
}
|
||||
nc = nc.replaceAll("'","''");
|
||||
if (trim) { nc = nc.trim();}
|
||||
nc = "'" + nc + "'";
|
||||
break;
|
||||
case "CLOB":
|
||||
nc = rs.getString(i);
|
||||
nc = rs.getString(i).replace("'","''");
|
||||
if (rs.wasNull() || nc == null) {
|
||||
nc = "NULL";
|
||||
break;
|
||||
}
|
||||
if (trim) { nc = nc.trim();}
|
||||
nc = "'" + nc + "'";
|
||||
break;
|
||||
case "CHAR":
|
||||
nc = rs.getString(i).replace("'","''");
|
||||
if (rs.wasNull() || nc == null) {
|
||||
nc = "NULL";
|
||||
break;
|
||||
}
|
||||
nc = nc.replaceAll("'","''");
|
||||
if (trim) { nc = nc.trim();}
|
||||
nc = "'" + nc + "'";
|
||||
break;
|
||||
@ -279,21 +239,19 @@ public class jrunner {
|
||||
}
|
||||
break;
|
||||
case "TIME":
|
||||
nc = rs.getString(i);
|
||||
nc = rs.getString(i).replace("'","''");
|
||||
if (rs.wasNull() || nc == null) {
|
||||
nc = "NULL";
|
||||
break;
|
||||
}
|
||||
nc.replaceAll("'","''");
|
||||
nc = "'" + nc + "'";
|
||||
break;
|
||||
case "TIMESTAMP":
|
||||
nc = rs.getString(i);
|
||||
nc = rs.getString(i).replace("'","''");
|
||||
if (rs.wasNull() || nc == null) {
|
||||
nc = "NULL";
|
||||
break;
|
||||
}
|
||||
nc.replaceAll("'","''");
|
||||
nc = "'" + nc + "'";
|
||||
break;
|
||||
case "BIGINT":
|
||||
@ -365,11 +323,6 @@ public class jrunner {
|
||||
e.printStackTrace();
|
||||
}
|
||||
System.out.println(" rows written");
|
||||
tsEnd = Timestamp.from(Instant.now());
|
||||
System.out.println(tsStart);
|
||||
System.out.println(tsEnd);
|
||||
//long time = Duration.between(tsStart, tsEnd).toMillis();
|
||||
//System.out.println("time elapsed: " + time);
|
||||
System.out.println();
|
||||
System.out.println("");
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +0,0 @@
|
||||
sudo cp app/build/distributions/app.zip /opt/
|
||||
sudo rm -rf /opt/app/
|
||||
sudo unzip /opt/app.zip -d /opt/
|
||||
sudo rm /opt/app.zip
|
||||
sudo chown $USER:$USER -R /opt/app/
|
||||
export JR="/opt/app/bin/app"
|
45
readme.md
45
readme.md
@ -1,45 +0,0 @@
|
||||
## install java jdk.
|
||||
find downloads page and get latest tarball.
|
||||
https://www.oracle.com/java/technologies/downloads/
|
||||
|
||||
```
|
||||
wget https://download.oracle.com/java/19/latest/jdk-19_linux-x64_bin.tar.gz
|
||||
tar -xvf downloaded_file
|
||||
```
|
||||
move the extracted folder to /opt
|
||||
put the extracted location in your path variable
|
||||
```
|
||||
export JAVA_HOME=/opt/jdk-19.0.1
|
||||
export PATH=$PATH:$JAVA_HOME/bin
|
||||
```
|
||||
|
||||
`java --version` to test
|
||||
|
||||
## install gradle
|
||||
https://docs.gradle.org/current/userguide/installation.html
|
||||
go to gradle.org and find the latest bin.zip file (burried in the `direct link` hyperlink)
|
||||
```
|
||||
wget https://services.gradle.org/distributions/gradle-7.6-bin.zip
|
||||
unzip -d /opt/gradle gradle-7.6-bin.zip
|
||||
```
|
||||
point to the gradle install
|
||||
```
|
||||
export PATH=$PATH:/opt/gradle/gradle-7.6/bin
|
||||
gradle -v` to validate
|
||||
```
|
||||
|
||||
## clone this repo
|
||||
clone
|
||||
`git clone https://gitea.hptrow.me/pt/jrunner.git`
|
||||
|
||||
build
|
||||
gradle build`
|
||||
|
||||
copy to opt for use
|
||||
```
|
||||
sudo cp app/build/distributions/app.zip /opt/
|
||||
sudo rm -rf /opt/app/
|
||||
sudo unzip /opt/app.zip -d /opt/
|
||||
sudo rm /opt/app.zip
|
||||
sudo chown ptrowbridge:ptrowbridge -R /opt/app/
|
||||
```
|
Loading…
Reference in New Issue
Block a user