Ispirer Toolkit automatically converts SQL Server to Java, considering its specifics
Both conversion with connection to the source database, as well as conversion of files containing SQL scripts are possible.
Make the most of automated migration to focus on your business core
Get started. Check migration plansIspirer Ecosystem automates your migration routine to enable quick and smart transformation of any database. Double the migration speed with our comprehensive solutions.
Trial is free. No payment
Trial is free. No payment
Ispirer has a solution to unlock the full potential of your database. Our team helps you to move business logic to an application layer seamlessly to advance the database performance.
Our automated migration engine analyzes the original Microsoft T-SQL code at the Abstract Syntax Tree (AST) level and accurately transforms:
Both conversion with connection to the source database, as well as conversion of files containing SQL scripts are possible.
Every database object (stored procedures, functions, etc.) is automatically transformed into a Java class. Names of the classes are formed based on object names, taking into account the Java Naming Convention.
At the same time, tables, views, triggers remain on the database side.
In this case, you need a Java application to work with a different database, Ispirer Toolkit can convert Embedded SQL and the database itself.
The tool automatically converts function and procedure variables to method variables.
SQL Server system functions and procedures are converted either to the same Java methods, if any, or to the methods of helper class.
This flexibility ensures that the generated code can be seamlessly integrated into different technology stacks while preserving familiar tools for working with the database.
Dive into tool’s features
More than 2K users use this way to
successfully convert their database
Ispirer Toolkit analyzes all object dependencies during the conversion process and provides not only line-by-line conversion, but resolves type conversions as well. The software understands and transforms the necessary inheritance dependencies. It parses the entire source code, builds an internal tree with all the information about the objects, and uses it in the migration process.
We convert SQL Server stored procedures to Java with attention to all the specifics
Microsoft SQL Server T-SQL
CREATE PROCEDURE sp_demo_conversion @DeptId INT, @EmployeeCount INT OUTPUT -- Output parameter AS BEGIN DECLARE @EmpId INT; DECLARE @EmpName NVARCHAR(100); DECLARE @CurrentDate DATETIME = GETDATE(); PRINT 'Procedure started at ' + CONVERT(VARCHAR, @CurrentDate, 120); BEGIN TRY -- Validate input parameter IF @DeptId IS NULL OR @DeptId <= 0 THROW 50001, 'Invalid Department Id', 1; -- Count employees in department and return via output parameter SELECT @EmployeeCount = COUNT(*) FROM Employees WHERE DeptId = @DeptId; PRINT 'Total employees in department: ' + CAST(@EmployeeCount AS VARCHAR); -- Exit early if no employees found IF @EmployeeCount = 0 BEGIN PRINT 'No employees found'; RETURN; END -- Cursor to iterate employees DECLARE emp_cursor CURSOR FOR SELECT EmpId, EmpName FROM Employees WHERE DeptId = @DeptId; OPEN emp_cursor; FETCH NEXT FROM emp_cursor INTO @EmpId, @EmpName; WHILE @@FETCH_STATUS = 0 BEGIN -- Conditional branch IF LEN(@EmpName) > 10 PRINT 'Long name: ' + @EmpName; ELSE PRINT 'Short name: ' + @EmpName; -- Try to update employee UPDATE Employees SET LastUpdated = @CurrentDate WHERE EmpId = @EmpId; FETCH NEXT FROM emp_cursor INTO @EmpId, @EmpName; END CLOSE emp_cursor; DEALLOCATE emp_cursor; END TRY BEGIN CATCH -- Collect error details DECLARE @ErrMsg NVARCHAR(4000) = ERROR_MESSAGE(); DECLARE @ErrNum INT = ERROR_NUMBER(); DECLARE @ErrSeverity INT = ERROR_SEVERITY(); DECLARE @ErrState INT = ERROR_STATE(); PRINT 'Error occurred: ' + @ErrMsg; -- Log error into a dedicated table INSERT INTO ErrorLog (ErrorDate, ErrorNumber, Severity, State, Message) VALUES (GETDATE(), @ErrNum, @ErrSeverity, @ErrState, @ErrMsg); -- Re-throw the error for higher-level handling THROW; END CATCH; PRINT 'Procedure finished at ' + CONVERT(VARCHAR, GETDATE(), 120); END
→ Java
import com.sql4j.db.cursor.*; import com.sql4j.db.implementation.Dao; import com.sql4j.db.util.ResultSetService; import com.sql4j.exception.*; import com.sql4j.transaction.aop.TransactionStatus; import com.sql4j.util.*; import java.time.LocalDateTime; import java.util.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.web.context.annotation.RequestScope; @Service @RequestScope public class SpDemoConversion implements ISpDemoConversion { @Autowired private ErrorUtil errorUtil; @Autowired private ResultSetService resultSetService; @Autowired private Dao dao; @Autowired private CursorStatusService cursorStatusService; @TransactionStatus @Override public Map< String, Object > spSpDemoConversion(Integer deptid, Integer employeecount) { Map<String, Object> outData = new HashMap<>(); outData.put("retStatus", 0); try { Integer empid = null; String empname = null; LocalDateTime currentdate = TimeUtil.getDate(); System.out.println(StringUtil.concatNullable("Procedure started at ", Converter.toString(currentdate, 120))); try { errorUtil.beginProtectedBlock(); if (deptid == null || ComparisonUtil.isLessOrEqual(deptid, 0)) { errorUtil.throwError(50001, "Invalid Department Id", 1); } dao.selectRes("SELECT COUNT(*) " + "FROM Employees " + "WHERE DeptId = :DEPTID ", "DEPTID", deptid); System.out.println(StringUtil.concatNullable("Total employees in department: ", Converter.toString(employeecount))); if (ComparisonUtil.areEqual(employeecount, 0)) { System.out.println("No employees found"); return outData; } CursorReader empCursor = new CursorReader(cursorStatusService, true, "SELECT EmpId, EmpName " + "FROM Employees " + "WHERE DeptId = :DEPTID ", "DEPTID", deptid); empCursor.open(); if (empCursor.fetchNext()) { empid = empCursor.getColumnValue(Integer.class); empname = empCursor.getColumnValue(String.class); } while (ComparisonUtil.areEqual(cursorStatusService.getFetchStatus(), 0)) { // Conditional branch if (ComparisonUtil.isGreaterThan(StringUtil.length(empname), 10)) { System.out.println(StringUtil.concatNullable("Long name: ", empname)); } else { System.out.println(StringUtil.concatNullable("Short name: ", empname)); } // Try to update employee dao.update("UPDATE Employees " + "SET LastUpdated = :CURRENTDATE " + "WHERE EmpId = :EMPID ", "CURRENTDATE", currentdate, "EMPID", empid); if (empCursor.fetchNext()) { empid = empCursor.getColumnValue(Integer.class); empname = empCursor.getColumnValue(String.class); } } empCursor.close(); empCursor.deallocate(); } catch (GeneralException e) { errorUtil.failProtectedBlock(); String errmsg = e.getMessage(); Integer errnum = e.getErrorNumber(); Integer errseverity = e.getSeverity(); Integer errstate = e.getState(); System.out.println(StringUtil.concatNullable("Error occurred: ", errmsg)); dao.update("INSERT INTO ErrorLog (ErrorDate, ErrorNumber, Severity, State, Message) " + "VALUES (GETDATE(), :ERRNUM, :ERRSEVERITY, :ERRSTATE, :ERRMSG) ", "ERRNUM", errnum, "ERRSEVERITY", errseverity, "ERRSTATE", errstate, "ERRMSG", errmsg); throw e; } finally { errorUtil.finalizeProtectedBlock(); } System.out.println(StringUtil.concatNullable("Procedure finished at ", Converter.toString(TimeUtil.getDate(), 120))); return outData; } finally { outData.put("dataSet", resultSetService.getResultSet()); outData.put("employeecount", employeecount); } } }
Fact 1/6
Applications can offer more flexibility and agility in managing and modifying business logic than databases. It's easier and faster to update and iterate on application code rather than altering database architecture, structure, stored procedures and data.
Fact 2/6
Business logic embedded within applications is more portable across different database systems or platforms. It can be beneficial if the business needs to switch database vendors or deploy the application in various environments.
Fact 3/6
Application servers are much easier to scale than database servers. Depending on the load users create, an application can be placed in a container and used as needed. It will be much easier and cheaper to achieve the system's desired performance using Ispirer solutions.
Fact 4/6
Having business logic in the application layer unties your hands if you plan to change a database management system. This approach allows the simultaneous support of several databases.
Fact 5/6
Migrating to Java can enable the adoption of new technologies and features, unlocking new business opportunities and driving innovation.
Fact 6/6
We perform the migration using the source code. There is no need for detailed documentation to begin the migration as there is in development.
Mixon, Magnit, CardinalHealth, and more have adopted SQLWays to boost their innovation life-cycle accelerate and manage their end-to-end innovation lifecycle
Take control of your database
migration now
It only takes 5 minutes!