Compare commits
8 Commits
Author | SHA1 | Date |
---|---|---|
Paul Trowbridge | b3a9151eff | |
Paul Trowbridge | e7b7d1bbba | |
Paul Trowbridge | 24fad6aa04 | |
Paul Trowbridge | b816399cba | |
Paul Trowbridge | fe39c6a2ae | |
pt | c67c7b1360 | |
Paul Trowbridge | 05508d8b26 | |
Paul Trowbridge | 1050930667 |
|
@ -26,6 +26,8 @@ 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 {
|
||||
|
|
|
@ -20,6 +20,7 @@ public class jrunner {
|
|||
String sq = "";
|
||||
String dt = "";
|
||||
Boolean trim = true;
|
||||
Boolean clear = true;
|
||||
Integer r = 0;
|
||||
Integer t = 0;
|
||||
String sql = "";
|
||||
|
@ -38,7 +39,7 @@ public class jrunner {
|
|||
Timestamp tsStart = null;
|
||||
Timestamp tsEnd = null;
|
||||
|
||||
msg = "jrunner version 0.38";
|
||||
msg = "jrunner version 0.41";
|
||||
msg = msg + nl + "-scu source jdbc url";
|
||||
msg = msg + nl + "-scn source username";
|
||||
msg = msg + nl + "-scp source passowrd";
|
||||
|
@ -48,6 +49,7 @@ 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-------------------------------------------------
|
||||
|
@ -99,6 +101,9 @@ public class jrunner {
|
|||
case "-t":
|
||||
trim = true;
|
||||
break;
|
||||
case "-c":
|
||||
clear = true;
|
||||
break;
|
||||
case "-v":
|
||||
System.out.println(msg);
|
||||
return;
|
||||
|
@ -198,15 +203,30 @@ 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]){
|
||||
switch (dtn[i].toUpperCase()){
|
||||
case "VARCHAR":
|
||||
nc = rs.getString(i);
|
||||
if (rs.wasNull() || nc == null) {
|
||||
|
@ -217,6 +237,16 @@ public class jrunner {
|
|||
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) {
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
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"
|
|
@ -0,0 +1,45 @@
|
|||
## 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