Class Db

  • All Implemented Interfaces:
    Recyclable

    public class Db
    extends java.lang.Object
    implements Recyclable
    An object containing contextual data for database spans
    • Constructor Summary

      Constructors 
      Constructor Description
      Db()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void copyFrom​(Db other)  
      long getAffectedRowsCount()  
      java.lang.String getDbLink()
      DB Link for connections between 2 databases
      java.lang.String getInstance()
      Database instance name
      java.lang.String getStatement()
      A database statement (e.g.
      java.nio.CharBuffer getStatementBuffer()
      Returns the associated pooled CharBuffer to record the DB statement.
      java.lang.String getType()
      Database type.
      java.lang.String getUser()
      Username for accessing database
      boolean hasContent()  
      void resetState()
      resets pooled object state so it can be reused
      Db withAffectedRowsCount​(long count)
      Sets the number of affected rows by statement execution
      Db withDbLink​(java.lang.String dbLink)
      DB Link for connections between 2 databases
      Db withInstance​(java.lang.String instance)
      Database instance name
      Db withStatement​(java.lang.String statement)
      A database statement (e.g.
      java.nio.CharBuffer withStatementBuffer()
      Gets a pooled CharBuffer to record the DB statement and associates it with this instance.
      Db withType​(java.lang.String type)
      Database type.
      Db withUser​(java.lang.String user)
      Username for accessing database
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Db

        public Db()
    • Method Detail

      • getInstance

        @Nullable
        public java.lang.String getInstance()
        Database instance name
      • withInstance

        public Db withInstance​(@Nullable
                               java.lang.String instance)
        Database instance name
      • getStatement

        @Nullable
        public java.lang.String getStatement()
        A database statement (e.g. query) for the given database type
      • withStatement

        public Db withStatement​(@Nullable
                                java.lang.String statement)
        A database statement (e.g. query) for the given database type
      • withStatementBuffer

        public java.nio.CharBuffer withStatementBuffer()
        Gets a pooled CharBuffer to record the DB statement and associates it with this instance.

        Note: you may not hold a reference to the returned CharBuffer as it will be reused.

        Note: This method is not thread safe

        Returns:
        a CharBuffer to record the DB statement
      • getStatementBuffer

        @Nullable
        public java.nio.CharBuffer getStatementBuffer()
        Returns the associated pooled CharBuffer to record the DB statement.

        Note: returns null unless withStatementBuffer() has previously been called

        Returns:
        a CharBuffer to record the DB statement, or null
      • getType

        @Nullable
        public java.lang.String getType()
        Database type. For any SQL database, "sql". For others, the lower-case database category, e.g. "cassandra", "hbase", or "redis"
      • withType

        public Db withType​(@Nullable
                           java.lang.String type)
        Database type. For any SQL database, "sql". For others, the lower-case database category, e.g. "cassandra", "hbase", or "redis"
      • getUser

        @Nullable
        public java.lang.String getUser()
        Username for accessing database
      • withUser

        public Db withUser​(@Nullable
                           java.lang.String user)
        Username for accessing database
      • getDbLink

        @Nullable
        public java.lang.String getDbLink()
        DB Link for connections between 2 databases
      • withDbLink

        public Db withDbLink​(@Nullable
                             java.lang.String dbLink)
        DB Link for connections between 2 databases
      • getAffectedRowsCount

        public long getAffectedRowsCount()
        Returns:
        number of affected rows by statement execution. A negative value might indicate feature is not supported by db/driver.
      • withAffectedRowsCount

        public Db withAffectedRowsCount​(long count)
        Sets the number of affected rows by statement execution
        Parameters:
        count - number of affected rows
        Returns:
        this
      • resetState

        public void resetState()
        Description copied from interface: Recyclable
        resets pooled object state so it can be reused
        Specified by:
        resetState in interface Recyclable
      • hasContent

        public boolean hasContent()
      • copyFrom

        public void copyFrom​(Db other)