arronbin edited a comment on issue #6080:
URL: https://github.com/apache/skywalking/issues/6080#issuecomment-754430829


   CREATE TABLE [dbo].[DEMO] (
   [Id] bigint NOT NULL IDENTITY(1,1) ,
   [CODE] varchar(50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL 
   CONSTRAINT [PK__DEMO__3214EC27BF799427] PRIMARY KEY ([Id])
   )
   ON [PRIMARY]
   GO
   
   DBCC CHECKIDENT(N'[dbo].[DEMO]', RESEED, 8)
   GO
   
   
   package com.demo.microservice.test;
   
   import java.sql.Connection;
   import java.sql.DriverManager;
   import java.sql.PreparedStatement;
   import java.sql.Statement;
   
   /**
    * @Auther: arronbin
    * @Date: 2021/1/5
    * @Description:
    */
   public class MssqlTest {
   
   
       public static void main(String [] args)
       {
           Connection conn = null;
           PreparedStatement p = null;
          try {
              Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
              conn = DriverManager.getConnection(
                      "jdbc:sqlserver://ip:1433;databasename=TestDB", "XX",
                      "XX");
               p = conn.prepareStatement("insert into demo(code)values(?)",
                              Statement.RETURN_GENERATED_KEYS);
              p.setString(1, "test");
              p.executeUpdate();
          }catch (Exception e){
              System.out.println(e.getMessage());
          }finally {
             try {
                 p.close();
                 conn.close();
             }catch (Exception e){
   
             }
          }
       }
   
   
   }
   
   
   Similar to https://github.com/apache/skywalking/issues/554
   @zifeihan @wu-sheng 


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to