Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Dynamically Set DataSource "schema" Attribute?

    I have a DataSource (Oracle) that looks like:
    Code:
    <DataSource 
    	schema="Bob"
    	dbName="Dobalina"
    	tableName="REQUESTS"
    	ID="REQUESTS"
    	dataSourceVersion="1"
    	serverType="sql"
    	justSomethingIMadeUp="shabammy"
    >
    
    	<fields>...
    Using the client-side class com.smartgwt.client.data.DataSource, I am able to read out the following XML attributes:
    Code:
    System.out.println("dbName:  " + requests.getAttribute("dbName"));
    System.out.println("ID:  " + requests.getAttribute("ID"));
    System.out.println("dataSourceVersion:  " + requests.getAttributeAsInt("dataSourceVersion"));
    System.out.println("serverType:  " + requests.getAttribute("serverType"));
    System.out.println("justSomethingIMadeUp:  " + requests.getAttribute("justSomethingIMadeUp"));
    But these "get" attempts return null:
    Code:
    System.out.println("schema:  " + requests.getAttribute("schema"));
    System.out.println("tableName:  " + requests.getAttribute("tableName"));
    My questions are:
    - Is it possible to read the "schema" attribute from a DataSource?
    - From Client side?
    - From Server side?

    Is it possible to WRITE the schema attribute to a DataSource? I think I would just need it in memory, for the duration of the session, not an actual write to the DataSource XML file.

    MY LARGER GOAL is to be able to more easily between switch target deployment environments (DEV to TEST to PROD) by a variable in Java code.

    I know I can switch db connection info w/ the server-side Config class; and I can supply other values I need as Velocity variables (e.g., ${urlHostname}, ${urlTargetSuffix}, etc).

    I'm just hung up on the DataSource "schema" attribute (and "dbName"). I'm guessing these two are withheld for security reasons?

    Any guidance appreciated, thanks.

    #2
    Right, these are withheld from the client for security reasons, along with lots of other attributes.

    The simple way to do what you want is keep the dbName and schema the same and change the definition via the Config class.

    If that's not feasible for some reason, you could register a DynamicDSGenerator so that you can provide the XML on the fly. But that's overkill really; keeping the dbName the same is better unless it's impossible in your environment.

    Comment

    Working...
    X