Forum Discussion
PaulDonny
11 years agoRegular Contributor
I am not a pro user but you can accomplish this rather simply with Groovy on the open source version.
The following is my DBRead function that I commonly use. It's a java function so you will need to add the correct imports in the code. I will put the ones I think are related to this specific function. Also, I use Access DB so that would need to be corrected as well.
And an example of it in use:
Like this you can control your DB as you like with the information you want. This code is quite barbaric and I rarely use it since the majority of my calls are now done with a Java app I created that I can point at any API and have it send what data I want to at it quite easily. I was using this to verify things like addresses were valid in my system.
The following is my DBRead function that I commonly use. It's a java function so you will need to add the correct imports in the code. I will put the ones I think are related to this specific function. Also, I use Access DB so that would need to be corrected as well.
import java.sql.*;
public static void dbWrite(String Database, String query) throws SQLException, ClassNotFoundException {
String currentDir = "/Dir/to/Database"
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String database = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=" + currentDir + Database;
Connection conn = DriverManager.getConnection(database, "", "");
Statement s = conn.createStatement();
s.execute(query);
conn.close();
}
}
And an example of it in use:
dbWrite("Resources.mdb", "UPDATE addresses SET Locals='" + locals + "' WHERE Zip like'" + zip[0] + "%';");
Like this you can control your DB as you like with the information you want. This code is quite barbaric and I rarely use it since the majority of my calls are now done with a Java app I created that I can point at any API and have it send what data I want to at it quite easily. I was using this to verify things like addresses were valid in my system.
Related Content
- 10 months agoLuukdb