Great! Thanks for the follow-up and the example code, very helpful.
On Thu, Feb 18, 2021 at 1:01 PM Lisa Ruby <lbru...@protonmail.com> wrote: > > Thank you again Bryan. I just got it working. From what I read about the > versioning, it would seem that being able to obtain only the major and minor > versions returned from > SYSCS_UTIL.SYSCS_GET_DATABASE_PROPERTY('DataDictionaryVersion') should be > enough to know if a database upgrade is needed. I'm assuming that the point > and fixpack versions would not contain changes extensive enough to require an > upgrade. > > In case anyone else is reading this and wants to know, here is Java code that > works for using > SYSCS_UTIL.SYSCS_GET_DATABASE_PROPERTY('DataDictionaryVersion'). > This obviously has no error or Exception handling. > It prints out the string "ddVersion = 10.11" for me on a database I haven't > yet upgraded to 10.15. > > import java.sql.Connection; > import java.sql.DriverManager; > import java.sql.Statement; > import java.sql.ResultSet; > > > String connectionURL = "jdbc:derby:dbname"; > Connection conn = DriverManager.getConnection(dbConnectionURL) > String ddVersionQueryStr = "values syscs_util.syscs_get_database_property( > 'DataDictionaryVersion' )"; > Statement stmt = conn.createStatement(); > boolean isResultSet = stmt.execute(ddVersionQueryStr); > ResultSet resultSet = stmt.getResultSet(); > resultSet.next(); > System.out.print("ddVersion = " + resultSet.getString(1) + "\n"); > > Lisa > > > On 2/18/2021 10:29 AM, Lisa Ruby wrote: > > I had not seen this Bryan. Thank you for pointing it out. Seems like it > would provide the information I'm looking for. I'll look into it. > > Lisa > > On 2/18/2021 6:48 AM, Bryan Pendleton wrote: > > Have you tried this? > https://db.apache.org/derby/docs/10.15/ref/rrefproperdatadictversion.html > > thanks, > > bryan > > On Wed, Feb 17, 2021 at 4:23 PM Lisa Ruby <lbru...@protonmail.com> wrote: > > Probably should have mentioned that I'm using derby version 10.15.2.0 > and AdoptOpenJDK Java 11.0.9.11-hotspot > > Lisa > > On 2/17/2021 4:08 PM, Lisa Ruby wrote: > > Hi, > > I am using derby in the embedded mode for a Java Windows desktop > application. I am trying to find a way that I can determine what version > my database is. When I use the Java Connection class > getMetaData().getDatabaseProductVersion() call it always returns the > version of the derby driver I am running, rather than the version of the > actual database. Or else it's returning the version of the database > after a soft upgrade, but not the underlying database version. Same for > getMetaData().getDatabaseMajorVersion() and > getMetaData().getDatabaseMinorVersion(). The reason I want to know the > version of the database is so I can determine if I need/want to do a > hard upgrade on the database. Is there any way for me to get the version > of the database from inside a Java program? > > Thank you. > > Lisa > > >