Reputation: 5017
I am having the followng error while starting TeamCity:
INFO - jetbrains.buildServer.STARTUP - Using database connection URL from the database properties file. The URL is: jdbc:hsqldb:file:$TEAMCITY_SYSTEM_PATH/buildserver
INFO - jetbrains.buildServer.STARTUP - Using internal (HSQL) database
INFO - jetbrains.buildServer.STARTUP - Current stage: Connecting to the database
ERROR - jetbrains.buildServer.STARTUP - Unexpected exception SQLException/HsqlException: SQL error when doing: Taking a connection from the data source SQL exception: error in script file line: C:\ProgramData\JetBrains\TeamCity\system\buildserver 278
INFO - jetbrains.buildServer.STARTUP - Current stage: TeamCity server startup error
Line 278 looks like this:
SET TABLE PUBLIC.PROBLEM INDEX '13402 13202 0 0 158'
Could you please help me? What could be the problem?
Upvotes: 4
Views: 5406
Reputation: 51
I had a similar problem - when we upgraded from 2024.07 to 2024.12 on Windows and connecting to SQL Server 2016 - 2019, the upgrade did not complete, and the server reported "Exception IllegalStateException in stage DB_CONNECT: Can't download JDBC driver as D:\TeamCity\lib\jdbc
not writable."
After searching the web, I tried creating the jdbc directory. That changed my error, but didn't help.
Right above the error was log message "Downloading JDBC driver metadata from ... download.jetbrains.com/teamcity/database-drivers/2024.12.xml?myVersion=2024.12&javaVersion=17.0.7 ...
I downloaded and looked in that file, noting it was pulling mssql-jdbc-12.6.0
I took a wild guess and copied mssql-jdbc-12.6.0.jre8.jar to .\lib\jdbc and mssql-jdbc_auth-12.6.0.x64.dll to .\lib\jdbc\native\windows-amd64
I also placed these in D:\TeamCity\system\caches\jdbc. I can't remember if I added it, but sqlserver12-win-auth.jar was also in caches\jdbc
After this, I was able to refresh the maintenance screen, enter a super user code and upgrade my database!
I pulled all files from ... https://learn.microsoft.com/en-us/sql/connect/jdbc/release-notes-for-the-jdbc-driver?view=sql-server-ver16#previous-releases
I THINK I needed to stop the Build Agent running on the same machine before upgrading.
I hope this helps someone!
Upvotes: 2
Reputation: 1088
If you get this error in 2022 like I did, check if Sql Browser Service is running. Turns out it needs to be running for Teamcity to start up.
Upvotes: 0
Reputation: 4622
In addition to Jonatan's answer, I determined my data directory by opening the log located at <Teamcity Home>/logs/teamcity-server.log
and searched for "data directory". In my case, it was C:\ProgramData\JetBrains\TeamCity\system
.
After I moved all the buildserver.*
files (in my case, it was buildserver.data
, buildserver.log
, buildserver.properties
), I opened the Teamcity UI in a browser and was prompted to enter the super user token. I determined the token by checking the end of the log at <Teamcity Home>/logs/teamcity-server.log
. After entering the token into the Teamcity UI, there was a confirmation to create a new database.
Upvotes: 0
Reputation: 5017
Got instructions like this: https://confluence.jetbrains.com/display/TCD10/Common+Problems#CommonProblems-Database-relatedissues
What is more, here is a related question: https://teamcity-support.jetbrains.com/hc/en-us/community/posts/206158469-SQL-error-when-doing-Taking-a-connection-from-the-data-source
It looks like database got corrupted. If you have backup, you need to restore from it. If not, you can only remove database and start without data, but configuration files will be preserved. For this you need to stop server and move files matching wildcard buildserver.* from /system/ directory to some other place and start server again.
Upvotes: 6