I am using Eclipse IDE for Java Developers version 2025-03 with WindowBuilder 1.20.0.202503172036 on Windows 10. My [Eclipse] Java project uses JDK 1.8.0_201. I am using Microsoft JDBC driver for SQL Server 12.10, specifically this JAR file: mssql-jdbc-12.10.0.jre8.jar
. The database is SQL Server 13.0.7050.2.
I use the following code to connect to the database from Java.
(Note that the below code uses fictitious host name and port and database name and user name and user password.)
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
java.util.Properties props = new java.util.Properties();
props.setProperty("password", "Mountbatten");
props.setProperty("userName", "Philip");
props.setProperty("databaseName", "Windsor");
props.setProperty("trustServerCertificate","true");
String url = "jdbc:sqlserver://balmoral:2024";
java.sql.Connection conn = java.sql.DriverManager.getConnection(url, props);
If I run this code from the main
method of a Java class the connection is established, however, from WindowBuilder, the connection is not established and the following stack trace appears in [Eclipse] workspace log file.
!ENTRY org.eclipse.wb.core 4 4 2025-05-11 10:30:10.134
!MESSAGE Designer [1.10.200.202503182030.202505110850]: Range [0, -14) out of bounds for length 1
!STACK 0
java.lang.StringIndexOutOfBoundsException: Range [0, -14) out of bounds for length 1
at java.base/jdk.internal.util.Preconditions$1.apply(Preconditions.java:55)
at java.base/jdk.internal.util.Preconditions$1.apply(Preconditions.java:52)
at java.base/jdk.internal.util.Preconditions$4.apply(Preconditions.java:213)
at java.base/jdk.internal.util.Preconditions$4.apply(Preconditions.java:210)
at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:98)
at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckFromToIndex(Preconditions.java:112)
at java.base/jdk.internal.util.Preconditions.checkFromToIndex(Preconditions.java:349)
at java.base/java.lang.String.checkBoundsBeginEnd(String.java:4865)
at java.base/java.lang.String.substring(String.java:2834)
at com.microsoft.sqlserver.jdbc.ConfigurableRetryLogic.getCurrentClassPath(ConfigurableRetryLogic.java:312)
at com.microsoft.sqlserver.jdbc.ConfigurableRetryLogic.readFromFile(ConfigurableRetryLogic.java:339)
at com.microsoft.sqlserver.jdbc.ConfigurableRetryLogic.setUpStatementRules(ConfigurableRetryLogic.java:207)
at com.microsoft.sqlserver.jdbc.ConfigurableRetryLogic.<init>(ConfigurableRetryLogic.java:89)
at com.microsoft.sqlserver.jdbc.ConfigurableRetryLogic.getInstance(ConfigurableRetryLogic.java:106)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:2600)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:2207)
at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:1320)
at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:683)
at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:191)
at idb.utils.sql.sqlserve.SqlSrvDb.getDbConnection(SqlSrvDb.java:159)
at idb.utils.sql.DbConFac.getDbConnection(DbConFac.java:99)
at idb.development.editors.Ct0TableModel.setData(IdbTableDataEditorGUI.java:324)
at idb.development.editors.IdbTableDataEditorGUI.populateTable(IdbTableDataEditorGUI.java:215)
at idb.development.editors.IdbTableDataEditorGUI.setPropertyData(IdbTableDataEditorGUI.java:125)
at qt.development.editors.QtPropertyEditorGUIAdapter.setPropertyData(QtPropertyEditorGUIAdapter.java:153)
at qt.development.editors.QtTableDataEditor.setValue(QtTableDataEditor.java:53)
at org.eclipse.wb.internal.swing.model.property.editor.beans.PropertyEditorWrapper$DialogPresentation.onClick(PropertyEditorWrapper.java:208)
at org.eclipse.wb.internal.core.model.property.editor.presentation.ButtonPropertyEditorPresentation.lambda$2(ButtonPropertyEditorPresentation.java:56)
at org.eclipse.draw2d.ButtonModel.lambda$0(ButtonModel.java:137)
at java.base/java.util.concurrent.CopyOnWriteArrayList.forEach(CopyOnWriteArrayList.java:891)
at org.eclipse.draw2d.ButtonModel.fireActionPerformed(ButtonModel.java:137)
at org.eclipse.draw2d.ButtonModel$DefaultFiringBehavior.released(ButtonModel.java:488)
at java.base/java.util.concurrent.CopyOnWriteArrayList.forEach(CopyOnWriteArrayList.java:891)
at org.eclipse.draw2d.ButtonModel.fireReleased(ButtonModel.java:170)
at org.eclipse.draw2d.ButtonModel.setPressed(ButtonModel.java:446)
at org.eclipse.draw2d.ClickableEventHandler.mouseReleased(ClickableEventHandler.java:108)
at org.eclipse.draw2d.Figure.handleMouseReleased(Figure.java:1040)
at org.eclipse.draw2d.SWTEventDispatcher.dispatchMouseReleased(SWTEventDispatcher.java:294)
at org.eclipse.gef.ui.parts.DomainEventDispatcher.dispatchMouseReleased(DomainEventDispatcher.java:426)
at org.eclipse.draw2d.LightweightSystem$EventHandler.mouseUp(LightweightSystem.java:598)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:258)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:91)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4321)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1208)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4119)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3707)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1151)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:339)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1042)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:153)
at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:668)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:339)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:576)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:173)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:178)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:208)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:149)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:115)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:467)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:298)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:670)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:607)
at org.eclipse.equinox.launcher.Main.run(Main.java:1492)
Note that prior to using Microsoft's JDBC driver, I was using jTDS driver which was successfully connecting with the exact same environment detailed above, i.e. same Eclipse, same WindowBuilder and same SQL Server database. Here is the jTDS code.
String url = "jdbc:jtds:sqlserver://balmoral:2024/Windsor";
java.util.Properties props = new java.util.Properties();
props.setProperty("password", "Mountbatten");
props.setProperty("user", "Philip");
java.sql.Connection conn = java.sql.DriverManager.getConnection(url, props);
I am asking for instructions on what I need to do in order to successfully connect to the SQL Server database from a JavaBeans custom editor in Eclipse WindowBuilder.
(12 May 2025)
From the link provided in this comment, it looks like the code of class com.microsoft.sqlserver.jdbc.ConfigurableRetryLogic
gets a URI like file:/
which it does not expect to get. As siggemannen mentioned in this comment, it appears to be a bug. I tried to report an issue on the GitHub page but I think I was unsuccessful.
I took a look at the source code and it looks like a bug in the microsoft jdbc driver, it tries to read a config file from classpath and fails when path isn't a simple url, like for example eclipse built-in classpath and others containers.
This bug was already reported at https://github.com/microsoft/mssql-jdbc/issues/2658 so you can probably downgrade the driver and upgrade when this issue is fixed, they're usually quite quick with fixes!