Migrating from Postgre to Microsoft SQL Server

Hi All,

We are currently on version 8.9.3 and running on Linux Vm with Postgre DB (OOTB Sonar).

We are looking to upgrade to 10.5 via 9.9 and planning to use Microsoft SQL Server as DB instead. We are unable to find any documentation on steps to migrate data from Postgre DB to Microsoft SQL Server DB. We do not want to lose user data and code analysis data during the upgrade.

Any information here to safely upgrade would be helpful.

Thank you.

Regards
Kumar

Hi,

Here is the documentation: SonarQube database copy tool

1 Like

Hi Felipe,

I tried the DB copy tool and getting a certificate error. I tried couple of combinations but it is still preventing the copy.

java -cp postgresql-42.2.19.jar:sonar-db-copy-1.6.0.2092-jar-with-dependencies.jar com.sonar.dbcopy.StartApp -urlSrc jdbc:postgresql://pqr.def.com/sonarqubedb -userSrc sonarqube -pwdSrc ***** -userDest mssqluser -pwdDest ****** -urlDest jdbc:sqlserver://abc.corp.def.com:1433

java -cp postgresql-42.2.19.jar:sonar-db-copy-1.6.0.2092-jar-with-dependencies.jar com.sonar.dbcopy.StartApp -urlSrc jdbc:postgresql://pqr.def.com/sonarqubedb -userSrc sonarqube -pwdSrc ***** -userDest mssqluser -pwdDest ****** -urlDest jdbc:sqlserver://abc.corp.def.com:1433;DatabaseName=SonarQube;encrypt=true;trustServerCertificate=true

12:20:26 INFO **************** CONFIGURATION VERIFICATIONS ****************
12:20:26 INFO Database SOURCE has been reached at : jdbc:postgresql://xxx.yyy.com/sonarqubedb
Exception in thread “main” com.sonar.dbcopy.utils.toolconfig.SqlDbCopyException: Database can not be reached at url jdbc:sqlserver://abc.corp.def.com:1433. Verify url, user name and password.
at com.sonar.dbcopy.prepare.ConnectionVerifier.databaseIsReached(ConnectionVerifier.java:31)
at com.sonar.dbcopy.StartApp.main(StartApp.java:74)
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption. Error: “PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target”. ClientConnectionId:e6f328ec-e32a-417d-8c90-d8641c742d74
at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:3806)
at com.microsoft.sqlserver.jdbc.TDSChannel.enableSSL(IOBuffer.java:1906)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:3329)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:2950)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:2790)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:1663)
at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:1064)
at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:681)
at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:229)
at com.sonar.dbcopy.prepare.ConnectionVerifier.databaseIsReached(ConnectionVerifier.java:24)
… 1 more
Caused by: javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:131)
at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:378)
at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:321)
at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:316)
at java.base/sun.security.ssl.CertificateMessage$T12CertificateConsumer.checkServerCerts(CertificateMessage.java:654)
at java.base/sun.security.ssl.CertificateMessage$T12CertificateConsumer.onCertificate(CertificateMessage.java:473)
at java.base/sun.security.ssl.CertificateMessage$T12CertificateConsumer.consume(CertificateMessage.java:369)
at java.base/sun.security.ssl.SSLHandshake.consume(SSLHandshake.java:396)
at java.base/sun.security.ssl.HandshakeContext.dispatch(HandshakeContext.java:480)
at java.base/sun.security.ssl.HandshakeContext.dispatch(HandshakeContext.java:458)
at java.base/sun.security.ssl.TransportContext.dispatch(TransportContext.java:201)
at java.base/sun.security.ssl.SSLTransport.decode(SSLTransport.java:172)
at java.base/sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl.java:1510)
at java.base/sun.security.ssl.SSLSocketImpl.readHandshakeRecord(SSLSocketImpl.java:1425)
at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:455)
at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:426)
at com.microsoft.sqlserver.jdbc.TDSChannel.enableSSL(IOBuffer.java:1795)
… 9 more
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at java.base/sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:439)
at java.base/sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:306)
at java.base/sun.security.validator.Validator.validate(Validator.java:264)
at java.base/sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:242)
at java.base/sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:113)
at com.microsoft.sqlserver.jdbc.HostNameOverrideX509TrustManager.checkServerTrusted(SQLServerTrustManager.java:86)
at java.base/sun.security.ssl.AbstractTrustManagerWrapper.checkServerTrusted(SSLContextImpl.java:1441)
at java.base/sun.security.ssl.CertificateMessage$T12CertificateConsumer.checkServerCerts(CertificateMessage.java:638)
… 21 more
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at java.base/sun.security.provider.certpath.SunCertPathBuilder.build(SunCertPathBuilder.java:148)
at java.base/sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:129)
at java.base/java.security.cert.CertPathBuilder.build(CertPathBuilder.java:297)
at java.base/sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:434)
… 28 more

We are able to ping the database server from our SonarQube server and the credentials have been validated. Is there a way to resolve the connection issue in the copy jar?

Your inputs will be valuable.

Regards
Kumar