Java Code Examples for net.sourceforge.jtds.jdbcx.JtdsDataSource#setCharset()

The following examples show how to use net.sourceforge.jtds.jdbcx.JtdsDataSource#setCharset() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JtdsDataSourceTest.java    From jTDS with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * ensure only non-null properties are added
 */
public void testAddNonNullProperties()
   throws Exception
{
     JtdsDataSource dataSource = new JtdsDataSource();
     dataSource.setServerName("non-null-value");
     dataSource.setDescription( null );
     dataSource.setCharset( null );

     Properties props = new Properties();

     Method m = JtdsDataSource.class.getDeclaredMethod( "addNonNullProperties", new Class[] {Properties.class, String.class, String.class} );
     m.setAccessible( true );
     m.invoke( dataSource, props, "user", null );

     assertEquals( 2, props.size() );
     assertEquals( "non-null-value", props.getProperty( Messages.get( Driver.SERVERNAME ) ) );
     assertEquals( "user", props.getProperty( Messages.get( Driver.USER ) ) );
}
 
Example 2
Source File: JtdsObjectFactoryTest.java    From jTDS with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void testGetterSetter()
   throws Exception
{
   HashMap defaults = new HashMap();

   defaults.put( "description"                       , "DESCRIPTION"                           );
   defaults.put( Driver.APPNAME                      , DefaultProperties.APP_NAME              );
   defaults.put( Driver.AUTOCOMMIT                   , DefaultProperties.AUTO_COMMIT           );
   defaults.put( Driver.BATCHSIZE                    , DefaultProperties.BATCH_SIZE_SQLSERVER  );
   defaults.put( Driver.BINDADDRESS                  , DefaultProperties.BIND_ADDRESS          );
   defaults.put( Driver.BUFFERDIR                    , DefaultProperties.BUFFER_DIR            );
   defaults.put( Driver.BUFFERMAXMEMORY              , DefaultProperties.BUFFER_MAX_MEMORY     );
   defaults.put( Driver.BUFFERMINPACKETS             , DefaultProperties.BUFFER_MIN_PACKETS    );
   defaults.put( Driver.CACHEMETA                    , DefaultProperties.CACHEMETA             );
   defaults.put( Driver.CHARSET                      , DefaultProperties.CHARSET               );
   defaults.put( Driver.DATABASENAME                 , DefaultProperties.DATABASE_NAME         );
   defaults.put( Driver.DOMAIN                       , DefaultProperties.DOMAIN                );
   defaults.put( Driver.INSTANCE                     , DefaultProperties.INSTANCE              );
   defaults.put( Driver.LANGUAGE                     , DefaultProperties.LANGUAGE              );
   defaults.put( Driver.LASTUPDATECOUNT              , DefaultProperties.LAST_UPDATE_COUNT     );
   defaults.put( Driver.LOBBUFFER                    , DefaultProperties.LOB_BUFFER_SIZE       );
   defaults.put( Driver.LOGFILE                      , DefaultProperties.LOGFILE               );
   defaults.put( Driver.LOGINTIMEOUT                 , DefaultProperties.LOGIN_TIMEOUT         );
   defaults.put( Driver.MACADDRESS                   , DefaultProperties.MAC_ADDRESS           );
   defaults.put( Driver.MAXSTATEMENTS                , DefaultProperties.MAX_STATEMENTS        );
   defaults.put( Driver.NAMEDPIPE                    , DefaultProperties.NAMED_PIPE            );
   defaults.put( Driver.PACKETSIZE                   , DefaultProperties.PACKET_SIZE_42        );
   defaults.put( Driver.PASSWORD                     , DefaultProperties.PASSWORD              );
   defaults.put( Driver.PORTNUMBER                   , DefaultProperties.PORT_NUMBER_SQLSERVER );
   defaults.put( Driver.PREPARESQL                   , DefaultProperties.PREPARE_SQLSERVER     );
   defaults.put( Driver.PROCESSID                    , DefaultProperties.PROCESS_ID            );
   defaults.put( Driver.PROGNAME                     , DefaultProperties.PROG_NAME             );
   defaults.put( Driver.SENDSTRINGPARAMETERSASUNICODE, DefaultProperties.USE_UNICODE           );
   defaults.put( Driver.SERVERNAME                   , "SERVERNAME"                            );
   defaults.put( Driver.SERVERTYPE                   , String.valueOf( Driver.SQLSERVER )      );
   defaults.put( Driver.SOKEEPALIVE                  , DefaultProperties.SOCKET_KEEPALIVE      );
   defaults.put( Driver.SOTIMEOUT                    , DefaultProperties.SOCKET_TIMEOUT        );
   defaults.put( Driver.SSL                          , DefaultProperties.SSL                   );
   defaults.put( Driver.TCPNODELAY                   , DefaultProperties.TCP_NODELAY           );
   defaults.put( Driver.TDS                          , DefaultProperties.TDS_VERSION_42        );
   defaults.put( Driver.USECURSORS                   , DefaultProperties.USECURSORS            );
   defaults.put( Driver.USEJCIFS                     , DefaultProperties.USEJCIFS              );
   defaults.put( Driver.USELOBS                      , DefaultProperties.USELOBS               );
   defaults.put( Driver.USENTLMV2                    , DefaultProperties.USENTLMV2             );
   defaults.put( Driver.USEKERBEROS                  , DefaultProperties.USEKERBEROS           );
   defaults.put( Driver.USER                         , DefaultProperties.USER                  );
   defaults.put( Driver.WSID                         , DefaultProperties.WSID                  );
   defaults.put( Driver.XAEMULATION                  , DefaultProperties.XAEMULATION           );

   JtdsObjectFactory jtdsObjectFactory = new JtdsObjectFactory();

   // create datasource using default values and check values
   JtdsDataSource ds = new JtdsDataSource( defaults );
   checkDefaults( ds );

   // create datasource from reference and check values
   checkDefaults( (JtdsDataSource) jtdsObjectFactory.getObjectInstance( ds.getReference(), null, null, null ) );

   // now us setters for modifying all properties and check via getter whether changes are applied
   ds.setDescription                  ( "TEST" ); assertEquals( "TEST", ds.getDescription()                   );
   ds.setAppName                      ( "TEST" ); assertEquals( "TEST", ds.getAppName()                       );
   ds.setAutoCommit                   ( false  ); assertEquals( false , ds.getAutoCommit()                    );
   ds.setBatchSize                    ( 123456 ); assertEquals( 123456, ds.getBatchSize()                     );
   ds.setBindAddress                  ( "1234" ); assertEquals( "1234", ds.getBindAddress()                   );
   ds.setBufferMaxMemory              ( 123456 ); assertEquals( 123456, ds.getBufferMaxMemory()               );
   ds.setBufferMinPackets             ( 123456 ); assertEquals( 123456, ds.getBufferMinPackets()              );
   ds.setCacheMetaData                ( true   ); assertEquals( true  , ds.getCacheMetaData()                 );
   ds.setCharset                      ( "1234" ); assertEquals( "1234", ds.getCharset()                       );
   ds.setDatabaseName                 ( "1234" ); assertEquals( "1234", ds.getDatabaseName()                  );
   ds.setDomain                       ( "1234" ); assertEquals( "1234", ds.getDomain()                        );
   ds.setInstance                     ( "1234" ); assertEquals( "1234", ds.getInstance()                      );
   ds.setLanguage                     ( "1234" ); assertEquals( "1234", ds.getLanguage()                      );
   ds.setLastUpdateCount              ( false  ); assertEquals( false , ds.getLastUpdateCount()               );
   ds.setLobBuffer                    ( 123456 ); assertEquals( 123456, ds.getLobBuffer()                     );
   ds.setLogFile                      ( "1234" ); assertEquals( "1234", ds.getLogFile()                       );
   ds.setLoginTimeout                 ( 123456 ); assertEquals( 123456, ds.getLoginTimeout()                  );
   ds.setMacAddress                   ( "1234" ); assertEquals( "1234", ds.getMacAddress()                    );
   ds.setMaxStatements                ( 123456 ); assertEquals( 123456, ds.getMaxStatements()                 );
   ds.setNamedPipe                    ( true   ); assertEquals( true  , ds.getNamedPipe()                     );
   ds.setPacketSize                   ( 123456 ); assertEquals( 123456, ds.getPacketSize()                    );
   ds.setPassword                     ( "1234" ); assertEquals( "1234", ds.getPassword()                      );
   ds.setPortNumber                   ( 123456 ); assertEquals( 123456, ds.getPortNumber()                    );
   ds.setPrepareSql                   ( 123456 ); assertEquals( 123456, ds.getPrepareSql()                    );
   ds.setProcessId                    ( "1234" ); assertEquals( "1234", ds.getProcessId()                     );
   ds.setProgName                     ( "1234" ); assertEquals( "1234", ds.getProgName()                      );
   ds.setSendStringParametersAsUnicode( false  ); assertEquals( false , ds.getSendStringParametersAsUnicode() );
   ds.setServerName                   ( "1234" ); assertEquals( "1234", ds.getServerName()                    );
   ds.setServerType                   ( 123456 ); assertEquals( 123456, ds.getServerType()                    );
   ds.setSocketKeepAlive              ( true   ); assertEquals( true  , ds.getSocketKeepAlive()               );
   ds.setSocketTimeout                ( 123456 ); assertEquals( 123456, ds.getSocketTimeout()                 );
   ds.setSsl                          ( "1234" ); assertEquals( "1234", ds.getSsl()                           );
   ds.setTcpNoDelay                   ( false  ); assertEquals( false , ds.getTcpNoDelay()                    );
   ds.setTds                          ( "1234" ); assertEquals( "1234", ds.getTds()                           );
   ds.setUseCursors                   ( true   ); assertEquals( true  , ds.getUseCursors()                    );
   ds.setUseJCIFS                     ( true   ); assertEquals( true  , ds.getUseJCIFS()                      );
   ds.setUseLOBs                      ( false  ); assertEquals( false , ds.getUseLOBs()                       );
   ds.setUseNTLMV2                    ( true   ); assertEquals( true  , ds.getUseNTLMV2()                     );
   ds.setUser                         ( "1234" ); assertEquals( "1234", ds.getUser()                          );
   ds.setWsid                         ( "1234" ); assertEquals( "1234", ds.getWsid()                          );
   ds.setXaEmulation                  ( false  ); assertEquals( false , ds.getXaEmulation()                   );
}