You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by GitBox <gi...@apache.org> on 2021/01/05 06:33:08 UTC

[GitHub] [skywalking] arronbin edited a comment on issue #6080: mssql error

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.homedo.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:
users@infra.apache.org