Hexagon Geospatial
MENU

GeoMedia Smart Client

GeoMedia Smart Client community discussion board is where you can create, contribute and share information and knowledge in regards to configuring as well as working with GeoMedia Smart Client. Find your answers, share your knowledge and help build a strong GeoMedia Smart Client community.
Showing results for 
Search instead for 
Do you mean 
Reply
Highlighted
Contributor
Posts: 66
Registered: ‎05-02-2016

Java SQL Connection Issues

Hi,

 

I have built a Java plugin which was working fine within Eclipse as of a few week ago.

Yesterday I opened the project and for some reason something reverted back so that it was using a JDBC connection that I previously created, which I know I changed so that it used the Intergraph tools for the SQL connection. Obviously I have done something accidently.


I am trying to get it working again using the Intergraph tools but the SQL component is failing this time round.

 

The error I get is 'Error! initDataSource has to be called first!'

 

Below is a snippet of code. There is also an update query with the same problem. I know where the error is raised, but I don't have a clue how it worked last time and not now. Am I meant to set up the data source as in our other Java projects I couldn't see this?

 

Connection connection = null;
PreparedStatement insertXMLTable = null;
try { //initial insert into XMLINSERTION when files are imported to GMSRVDEV, also populates triggerfield
                                     	
	connection = DatabaseConnectorFactory.getInstance().getDatabaseConnector(HatBoxDatabaseConnector.class).getConnection();                    	
                                                                                            
        insertXMLTable = connection.prepareStatement("INSERT INTO Bushland_Dev.dbo.XMLINSERTION (FILEPATH, FILENAME, TRIGGERFIELD) VALUES (?,?,?)"); //preparestatement to pass variables into, don't use concatenation as it is vulnerable to injection
                                               
        insertXMLTable.setString(1,destination.toString());
        insertXMLTable.setString(2,destination.getFileName().toString());
        insertXMLTable.setString(3,GMSCKey);
        insertXMLTable.executeUpdate();
                          
        connection.close();
    } catch (Exception e) {
        System.err.println("Error!");
        System.err.println(e.getMessage());
    }

Hopefully that all makes sense.

 

I am fairly new to Java so it is probably something I have done.

 

Regards,

 

Josh

Do you need immediate support?
If you encounter a critical issue and need immediate assistance please submit a Service Request through our Support Portal.