Hi Michaël,

I know, I must to learn more, more, more about the insides of openjump,
java, eclipse, git, etc but now I had to listen to "I Got You (I Feel
Good)" by James Brown...!  Thx! 😊

I can connect to database and get what I want but I had to modify the code,
because the "DriverManager.getConnection(url, user, pwd)" threw the "The
method getConnection(String, String, String) is undefined for the type
DriverManager" error. I must use this:
"java.sql.DriverManager.getConnection(url, user, pwd)" and voilà! (It works
similarly using Properties/setProperty() too.)

The  'Class.forName("org.postgresql.Driver"); was not neccessary.

The tasks I have to solve is multifaceted and involves too many clicks at
now. I need to program these steps to make openjump efficient and
user-friendly. The project files are not sufficient for this.

Thx again!!!

Regards,
János


Michaud Michael via Jump-pilot-devel <jump-pilot-devel@lists.sourceforge.net>
ezt írta (időpont: 2024. júl. 15., H, 22:27):

> Hi Janos,
>
>
> >> but how can I transfer data from e.g. postgis ?
>
> Here is a small example (not tested) importing a query result as a layer :
>
> (you may have to initiate postgresql driver with 'Class.forName("org.
> postgresql.Driver");'
>
> try {
>   String url = "jdbc:postgresql://<host>:<port>/<database>";
>   String user = <user>;
>   String pwd = <pwd>;
>   String query = <query>;
>   PostgisDSConnection connection = new PostgisDSConnection(
> DriverManager.getConnection(url, user, pwd));
>   FeatureInputStream fis = connection.execute(new AdhocQuery(query));
>   FeatureCollection dataset = new FeatureDataset(fis.getFeatureSchema());
>   while (fis.hasNext()) {
>     dataset.add(fis.next());
>   }
>   pluginContext.getLayerManager().addLayer(category, layerName, dataset);
> } catch(Exception ex) {
>   ex.printStackTrace();
> }
>
>
> I you want to link a postgis table to your project as a dynamic table, you
> can refer to the following class :
>
> AddDataStoreLayerWizard
>
> (There is also a different wizard for writable layer)
>
> Not sure what you want to do. If you just want to open OpenJUMP with a
> layer connected to a database,
>
> you can do it from the menu and save it in a project.
>
> Michaël
> _______________________________________________
> Jump-pilot-devel mailing list
> Jump-pilot-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel
>
_______________________________________________
Jump-pilot-devel mailing list
Jump-pilot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel

Reply via email to