Home
%3CLINGO-SUB%20id%3D%22lingo-sub-368727%22%20slang%3D%22en-US%22%3EMigrate%20your%20Java%20applications%20from%20Oracle%20to%20SQL%20Server%20with%20the%20help%20of%20the%20Data%20Access%20Migration%20Toolkit%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-368727%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSTRONG%3E%20First%20published%20on%20MSDN%20on%20Feb%2002%2C%202019%20%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CI%3E%20Authored%20by%20datamigrationteam%40microsoft.com%20%3C%2FI%3E%3C%2FP%3E%0A%3CP%3E%3CBR%20%2F%3EChanging%20database%20vendors%20is%20not%20an%20easy%20task%2C%20but%20a%20lot%20of%20people%20do%20it%20and%20for%20multiple%20reasons%20including%20better%20pricing%20or%20features.%20Microsoft%20provides%20a%20free%20tool%20called%20the%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsql%2Fssma%2Fsql-server-migration-assistant%3Fview%3Dsql-server-2017%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%20SQL%20Server%20Migration%20Assistant%20%3C%2FA%3E%20(SSMA)%2C%20which%20can%20assist%20with%20your%20database%20migration%20needs.%20While%20SSMA%20offers%20comprehensive%20support%20for%20database%20schema%20migration%2C%20the%20application%20code%20required%20manual%20updates%20to%20support%20the%20new%20database%20back%20end.%20Today%20Microsoft%20is%20introducing%20the%20%3CA%20href%3D%22https%3A%2F%2Fmarketplace.visualstudio.com%2Fitems%3FitemName%3Dms-databasemigration.data-access-migration-toolkit%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%20Data%20Access%20Migration%20Toolkit%20%3C%2FA%3E%20%2C%20which%20is%20designed%20to%20help%20close%20this%20gap.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1678996551%22%20id%3D%22toc-hId-1704674500%22%3EWhat%20is%20the%20Data%20Access%20Migration%20Toolkit%3F%3C%2FH2%3E%0A%3CP%3EMaking%20changes%20to%20the%20application%20code%20is%20a%20significant%20challenge%20during%20database%20migration.%20How%20should%20this%20be%20addressed%3F%20We%20could%20add%20support%20for%20source%20code%20analysis%20in%20SSMA.%20However%2C%20the%20people%20editing%20the%20application%20are%20not%20necessarily%20the%20same%20people%20that%20are%20addressing%20the%20database%20schema%2C%20so%20they%20may%20not%20be%20using%20the%20same%20tool%20set.%20We%20could%20roll%20out%20new%20tool%20solely%20for%20this%20purpose%2C%20but%20that%20would%20introduce%20a%20learning%20curve%20for%20application%20developers.%20Instead%2C%20we%20have%20decided%20to%20build%20on%20existing%20developer%20tools%20that%20everybody%20knows%20and%20loves%20%E2%80%93%20%3CA%20href%3D%22https%3A%2F%2Fcode.visualstudio.com%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%20Visual%20Studio%20Code%20%3C%2FA%3E%20!%20The%20%3CSTRONG%3E%20Data%20Access%20Migration%20Toolkit%20%3C%2FSTRONG%3E%20is%20an%20extension%20for%20Visual%20Studio%20Code%20that%20allows%20you%20to%20analyze%20your%20Java%20source%20code%20and%20detect%20data%20access%20API%20calls%20and%20queries%2C%20providing%20you%20with%20a%20single-pane%20view%20of%20what%20needs%20to%20be%20addressed%20to%20support%20the%20new%20database%20back%20end.%20%3CBR%20%2F%3E%3CBR%20%2F%3EThere%20are%20a%20lot%20of%20variables%20in%20migrations%2C%20such%20as%20different%20programming%20languages%20and%20database%20engines.%20However%2C%20we%20had%20to%20start%20somewhere%2C%20so%20we%20decided%20to%20focus%20on%20Java%20applications%20accessing%20Oracle%20databases%20as%20our%20first%20scenario.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--873160410%22%20id%3D%22toc-hId--847482461%22%3EGetting%20started%3C%2FH2%3E%0A%3CP%3EThe%20Data%20Access%20Migration%20Toolkit%20extension%20is%20free%20and%20available%20through%20the%20Visual%20Studio%20Marketplace.%20To%20install%20the%20toolkit%2C%20just%20open%20%3CSTRONG%3E%20Visual%20Studio%20Code%20%3C%2FSTRONG%3E%20%2C%20navigate%20to%20%3CSTRONG%3E%20Extensions%20%3C%2FSTRONG%3E%20tab%2C%20search%20for%20%3CSTRONG%3E%20Data%20Access%20Migration%20Toolkit%20%3C%2FSTRONG%3E%20%2C%20select%20it%20in%20the%20list%2C%20and%20then%20select%20%3CSTRONG%3E%20Install%20%3C%2FSTRONG%3E%20.%20The%20process%20should%20not%20take%20long%20to%20complete.%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20381px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F88835i31BC485D3B5091D0%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20%2F%3E%3C%2FSPAN%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3EWhen%20the%20installation%20is%20complete%2C%20reload%20Visual%20Studio%20Code%20and%20you%20are%20all%20set%20to%20analyze%20your%20app!%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-869649925%22%20id%3D%22toc-hId-895327874%22%3EUsing%20the%20extension%3C%2FH2%3E%0A%3CP%3ETo%20start%20analyzing%20your%20Java%20source%20code%2C%20you%20first%20need%20to%20load%20it%20in%20the%20work%20space.%20If%20you%20are%20already%20familiar%20Visual%20Studio%20Code%20%E2%80%93%20good!%20If%20not%2C%20then%20just%20navigate%20to%20the%20%3CSTRONG%3E%20Explorer%20%3C%2FSTRONG%3E%20tab%20and%20select%20%3CSTRONG%3E%20Open%20Folder%20%3C%2FSTRONG%3E%20.%20If%20you%20don%E2%80%99t%20have%20the%20necessary%20extensions%20to%20work%20with%20Java%20code%2C%20Visual%20Studio%20Code%20will%20prompt%20you%20to%20install%20them.%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20463px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F88836iDC7EA4826E9A018E%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20%2F%3E%3C%2FSPAN%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3EThe%20Data%20Access%20Migration%20Toolkit%20relies%20on%20the%20%3CSTRONG%3E%20redhat.java%20%3C%2FSTRONG%3E%20extension%20for%20analysis%2C%20so%20make%20sure%20you%20have%20this%20installed.%20This%20extension%20is%20part%20of%20the%20%3CSTRONG%3E%20Java%20Extension%20Pack%20%3C%2FSTRONG%3E%20%2C%20which%20is%20the%20most%20common%20setup.%20%3CBR%20%2F%3E%3CBR%20%2F%3EAfter%20your%20folder%20is%20loaded%20and%20ready%20to%20use%2C%20just%20run%20the%20%3CSTRONG%3E%20Data%20access%3A%20Analyze%20workspace%20%3C%2FSTRONG%3E%20command%20(press%20%3CSTRONG%3E%20%3CCTRL%3E%20%3C%2FCTRL%3E%3C%2FSTRONG%3E%20%2B%20%3CSTRONG%3E%20%3CSHIFT%3E%20%3C%2FSHIFT%3E%3C%2FSTRONG%3E%20%2B%20%3CSTRONG%3E%20P%20%3C%2FSTRONG%3E%20and%20start%20typing%20%E2%80%9C%20%3CEM%3E%20Data%20acc...%20%3C%2FEM%3E%20%E2%80%9D).%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20622px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F88837i2CCDF49ACCA25060%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20%2F%3E%3C%2FSPAN%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3ESelect%20the%20command%2C%20and%20then%20give%20it%20some%20time%20to%20scan%20through%20your%20work%20space.%20Depending%20on%20the%20size%20of%20your%20project%2C%20this%20may%20take%20a%20few%20minutes.%20After%20the%20analysis%20is%20done%2C%20the%20%3CSTRONG%3E%20Problems%20%3C%2FSTRONG%3E%20pane%20will%20list%20all%20locations%20of%20interest%20that%20have%20been%20identified.%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20624px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F88838i23024137812281C9%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20%2F%3E%3C%2FSPAN%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3EThe%20command%20will%20also%20generate%20a%20report%20calling%20out%20the%20places%20in%20your%20code%20base%20that%20may%20need%20to%20be%20updated%20when%20migrating%20to%20a%20different%20database%20back%20end.%20%3CBR%20%2F%3E%3CBR%20%2F%3ECurrently%20the%20extension%20detects%20the%20following%3A%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EJDBC%20and%20Java%20Persistence%20API%20calls%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EConnection%20strings%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EString%20literals%20that%20look%20like%20a%20database%20query%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CBR%20%2F%3EThe%20extension%20analyzes%20all%20relevant%20files%2C%20including%20XML%2C%20JSON%2C%20and%20arbitrary%20Java%20properties%20files%2C%20in%20your%20work%20space.%20In%20our%20example%2C%20all%20data%20access%20artifacts%20existed%20in%20.java%20files.%20Let%E2%80%99s%20explore%20what%20needs%20to%20be%20changed.%20%3CBR%20%2F%3E%3CBR%20%2F%3EThe%20first%20thing%20identified%20is%20the%20connection%20string%20to%20the%20database.%20Click%20on%20that%20problem%2C%20and%20you%20are%20taken%20to%20the%20location%20where%20the%20connection%20string%20is%20defined.%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20624px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F88839i091825030485E766%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20%2F%3E%3C%2FSPAN%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3EIn%20this%20case%2C%20just%20change%20the%20connection%20string%20to%20use%20the%20SQL%20Server%20driver%2C%20and%20then%20move%20on.%20After%20you%20update%20the%20connection%20string%20and%20save%20the%20file%20%E2%80%93%20the%20extension%20will%20automatically%20reanalyze%20the%20contents%20and%20update%20the%20problems%20pane%20with%20the%20most%20recent%20scan%20results.%20%3CBR%20%2F%3E%3CBR%20%2F%3EThe%20next%20problem%20identified%20points%20to%20the%20%3CSTRONG%3E%20DriverManager.getConnection(..)%20%3C%2FSTRONG%3E%20API%20call%3A%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20624px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F88840iA57702FC1EE746D5%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20%2F%3E%3C%2FSPAN%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3EIn%20this%20case%2C%20review%20the%20connection%20information%20and%20make%20sure%20everything%20is%20pointing%20to%20the%20SQL%20Server.%20Luckily%2C%20in%20our%20case%20the%20connection%20string%20is%20defined%20somewhere%20else%20(a%20constant%20field%20that%20we%20already%20fixed)%2C%20so%20no%20actions%20are%20required.%20However%2C%20we%20still%20want%20to%20ensure%20this%20problem%20is%20resolved%2C%20so%20we%20can%20suppress%20the%20issue%20by%20adding%20a%20special%20%3CSTRONG%3E%20damt.ignore-next-line%20%3C%2FSTRONG%3E%20comment%20directly%20before%20it%3A%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20624px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F88841iEBC6D210D226231F%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20%2F%3E%3C%2FSPAN%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3EWe%20specify%20%3CSTRONG%3E%20api-reference%20%3C%2FSTRONG%3E%20in%20brackets%20since%20this%20is%20the%20warning%20type%20that%20we%20want%20to%20suppress.%20%3CBR%20%2F%3E%3CBR%20%2F%3EMoving%20on%20to%20the%20final%20two%20problems%2C%20notice%20that%20they%20are%20on%20the%20same%20line%3A%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20624px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F88842iA2F3B222C1233C03%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20%2F%3E%3C%2FSPAN%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3EThe%20first%20one%20is%20a%20%3CSTRONG%3E%20Connection.prepareStatement(..)%20%3C%2FSTRONG%3E%20call%20and%20the%20second%20one%20is%20the%20actual%20query.%20At%20times%20you%20may%20have%20queries%20coming%20from%20user%20input%20or%20loaded%20from%20an%20external%20file%2C%20so%20query%20detection%20alone%20will%20not%20be%20a%20reliable%20approach.%20To%20be%20on%20the%20safe%20side%20and%20ensure%20that%20you%20detect%20all%20potential%20problems%2C%20the%20Data%20Access%20Migration%20Toolkit%20also%20marks%20calls%20to%20data%20access%20APIs%20for%20your%20review%20so%20that%20you%20can%20make%20sure%20that%20the%20queries%20being%20used%20are%20compatible%20with%20new%20database%20back%20end.%20In%20this%20case%20we%20have%20a%20query%20right%20there%2C%20so%20we%20can%20suppress%20the%20API%20warning%20right%20away%20and%20focus%20on%20the%20query.%20%3CBR%20%2F%3E%3CBR%20%2F%3EIf%20you%20used%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsql%2Fssma%2Foracle%2Fsql-server-migration-assistant-for-oracle-oracletosql%3Fview%3Dsql-server-2017%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%20SQL%20Server%20Migration%20Assistant%20%3C%2FA%3E%20to%20migrate%20your%20database%20back%20end%20from%20Oracle%20to%20SQL%20Server%2C%26nbsp%3Bthen%26nbsp%3Byou%20can%20use%20the%20%3CA%20href%3D%22https%3A%2F%2Fblogs.msdn.microsoft.com%2Fssma%2F2010%2F09%2F21%2Fhow-to-convert-individual-statement-using-ssma%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%20statement%20conversion%20feature%20%3C%2FA%3E%20to%26nbsp%3Bconvert%26nbsp%3Bqueries%26nbsp%3Bwithin%20your%20migration%20project.%26nbsp%3BFor%20this%20walk-through%2C%26nbsp%3Bwe%20will%20modify%20the%20query%20to%20be%20compatible%20with%20SQL%20Server%26nbsp%3Bourselves%26nbsp%3B%E2%80%93%20all%20we%26nbsp%3Bneed%20to%26nbsp%3Bdo%26nbsp%3Bis%20use%20%E2%80%98%2B%E2%80%99%20for%20string%20concatenation%3A%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20624px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F88843i5CD071AA48EE83F9%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20%2F%3E%3C%2FSPAN%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3ENotice%20that%20the%20suppression%20attribute%20has%20two%20warning%20types%3A%20%3CSTRONG%3E%20api-reference%20%3C%2FSTRONG%3E%20and%20%3CSTRONG%3E%20query%20%3C%2FSTRONG%3E%20.%20I%20already%20mentioned%20that%20there%20is%20nothing%20to%20do%20about%20%3CSTRONG%3E%20prepareStatement(..)%20%3C%2FSTRONG%3E%20call%20in%20this%20case%2C%20but%20the%20query%20is%20already%20fixed%2C%20so%20why%20would%20we%20suppress%20the%20warning%3F%20That%E2%80%99s%20where%20it%20gets%20tricky%20%E2%80%93%20some%20queries%20look%20very%20similar%20between%20Oracle%20and%20SQL%20Server%2C%20so%20the%20extension%20cannot%20tell%20whether%20a%20query%20will%20work%20with%20your%20new%20database%20back%20end.%20As%20a%20result%2C%20after%20you%20modify%20the%20query%20it%20is%20recommended%20to%20mark%20it%20as%20fixed%20by%20adding%20the%20suppression%20comment%20next%20to%20it%20%E2%80%93%20this%20will%20help%20you%20track%20the%20progress%20as%20you%20move%20along.%20%3CBR%20%2F%3E%3CBR%20%2F%3EAfter%20you%20are%20done%20%E2%80%93%20save%20the%20file%2C%20and%20the%20extension%20will%20reanalyze%20the%20file%20and%20clear%20all%20the%20warnings!%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--1682507036%22%20id%3D%22toc-hId--1656829087%22%3EWhat%E2%80%99s%20next%3F%3C%2FH2%3E%0A%3CP%3EIf%20you%20are%20in%20the%20process%20of%20migrating%20your%20database%20%E2%80%93%20go%20and%20try%20it%20yourself%20today%3A%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EGet%20%3CA%20href%3D%22https%3A%2F%2Fcode.visualstudio.com%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%20Visual%20Studio%20Code%3C%2FA%3E.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EInstall%20the%20%3CA%20href%3D%22https%3A%2F%2Fmarketplace.visualstudio.com%2Fitems%3FitemName%3Dms-databasemigration.data-access-migration-toolkit%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%20Data%20Access%20Migration%20Toolkit%20extension%3C%2FA%3E.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CBR%20%2F%3EThis%20is%20just%20a%20first%20step%20in%20our%20journey%20to%20simplify%20application%20code%20remediation%20when%20you%20migrate%20to%20SQL%20Server%2C%20so%20stay%20tuned%20%E2%80%93%20there%20is%20more%20to%20come!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-368727%22%20slang%3D%22en-US%22%3E%3CP%3EFirst%20published%20on%20MSDN%20on%20Feb%2002%2C%202019%20Authored%20by%20datamigrationteam%40microsoft.%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-368727%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EData%20Access%20Migration%20Toolkit%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Microsoft

First published on MSDN on Feb 02, 2019

Authored by datamigrationteam@microsoft.com


Changing database vendors is not an easy task, but a lot of people do it and for multiple reasons including better pricing or features. Microsoft provides a free tool called the SQL Server Migration Assistant (SSMA), which can assist with your database migration needs. While SSMA offers comprehensive support for database schema migration, the application code required manual updates to support the new database back end. Today Microsoft is introducing the Data Access Migration Toolkit , which is designed to help close this gap.

 

What is the Data Access Migration Toolkit?

Making changes to the application code is a significant challenge during database migration. How should this be addressed? We could add support for source code analysis in SSMA. However, the people editing the application are not necessarily the same people that are addressing the database schema, so they may not be using the same tool set. We could roll out new tool solely for this purpose, but that would introduce a learning curve for application developers. Instead, we have decided to build on existing developer tools that everybody knows and loves – Visual Studio Code ! The Data Access Migration Toolkit is an extension for Visual Studio Code that allows you to analyze your Java source code and detect data access API calls and queries, providing you with a single-pane view of what needs to be addressed to support the new database back end.

There are a lot of variables in migrations, such as different programming languages and database engines. However, we had to start somewhere, so we decided to focus on Java applications accessing Oracle databases as our first scenario.

 

Getting started

The Data Access Migration Toolkit extension is free and available through the Visual Studio Marketplace. To install the toolkit, just open Visual Studio Code , navigate to Extensions tab, search for Data Access Migration Toolkit , select it in the list, and then select Install . The process should not take long to complete.



When the installation is complete, reload Visual Studio Code and you are all set to analyze your app!

 

Using the extension

To start analyzing your Java source code, you first need to load it in the work space. If you are already familiar Visual Studio Code – good! If not, then just navigate to the Explorer tab and select Open Folder . If you don’t have the necessary extensions to work with Java code, Visual Studio Code will prompt you to install them.



The Data Access Migration Toolkit relies on the redhat.java extension for analysis, so make sure you have this installed. This extension is part of the Java Extension Pack , which is the most common setup.

After your folder is loaded and ready to use, just run the Data access: Analyze workspace command (press <Ctrl> + <Shift> + P and start typing “ Data acc... ”).



Select the command, and then give it some time to scan through your work space. Depending on the size of your project, this may take a few minutes. After the analysis is done, the Problems pane will list all locations of interest that have been identified.



The command will also generate a report calling out the places in your code base that may need to be updated when migrating to a different database back end.

Currently the extension detects the following:

    • JDBC and Java Persistence API calls
    • Connection strings
    • String literals that look like a database query


The extension analyzes all relevant files, including XML, JSON, and arbitrary Java properties files, in your work space. In our example, all data access artifacts existed in .java files. Let’s explore what needs to be changed.

The first thing identified is the connection string to the database. Click on that problem, and you are taken to the location where the connection string is defined.



In this case, just change the connection string to use the SQL Server driver, and then move on. After you update the connection string and save the file – the extension will automatically reanalyze the contents and update the problems pane with the most recent scan results.

The next problem identified points to the DriverManager.getConnection(..) API call:



In this case, review the connection information and make sure everything is pointing to the SQL Server. Luckily, in our case the connection string is defined somewhere else (a constant field that we already fixed), so no actions are required. However, we still want to ensure this problem is resolved, so we can suppress the issue by adding a special damt.ignore-next-line comment directly before it:



We specify api-reference in brackets since this is the warning type that we want to suppress.

Moving on to the final two problems, notice that they are on the same line:



The first one is a Connection.prepareStatement(..) call and the second one is the actual query. At times you may have queries coming from user input or loaded from an external file, so query detection alone will not be a reliable approach. To be on the safe side and ensure that you detect all potential problems, the Data Access Migration Toolkit also marks calls to data access APIs for your review so that you can make sure that the queries being used are compatible with new database back end. In this case we have a query right there, so we can suppress the API warning right away and focus on the query.

If you used SQL Server Migration Assistant to migrate your database back end from Oracle to SQL Server, then you can use the statement conversion feature to convert queries within your migration project. For this walk-through, we will modify the query to be compatible with SQL Server ourselves – all we need to do is use ‘+’ for string concatenation:



Notice that the suppression attribute has two warning types: api-reference and query . I already mentioned that there is nothing to do about prepareStatement(..) call in this case, but the query is already fixed, so why would we suppress the warning? That’s where it gets tricky – some queries look very similar between Oracle and SQL Server, so the extension cannot tell whether a query will work with your new database back end. As a result, after you modify the query it is recommended to mark it as fixed by adding the suppression comment next to it – this will help you track the progress as you move along.

After you are done – save the file, and the extension will reanalyze the file and clear all the warnings!

 

What’s next?

If you are in the process of migrating your database – go and try it yourself today:


This is just a first step in our journey to simplify application code remediation when you migrate to SQL Server, so stay tuned – there is more to come!