Byte[] to float?

Hi,
I'm trying to write an applet which talks to its parent server. The server sends a series of floats (4 bytes each) to the applet, which is stored to a byte array by BufferedInputStream.read(buffer, 0, 4). I need to convert those 4-byte-sized byte array to a float like this:
float Number = (float)ByteArray; // Doesn't work!
Is there any helper functions in java to do this? Or should I send the numbers as plain text through the network, and then convert from String to float instead? (Obviously I don't wanna do that due to great performance hit)
Any help would be greatly appreciated. Thanks!
Aaron

It is possible to convert a byte array to a float:
* Converts an array of bytes to a float.
* @param arr  an array of 4 bytes to be converted
* @return a float value comprising the bytes in
static float byteArrayToFloat(final byte[] arr) {
   int bits = (arr[0] << 24) | (arr[1] << 16) |
                (arr[2] << 8) | arr[3];
   return Float.intBitsToFloat(bits);
}But why not just use a DataInputStream?

Similar Messages

  • Converting Byte [] into float []

    Hi, I read the contents of a file into a byte array and am now trying to convert it into a float array.
    here is the code I am using
    public static float [] bytetofloat(byte [] convert){
        float [] data = new float [convert.length/2];
        for(int i = 0;i<convert.length;i+=2){
            for(int j = 0; j <data.length;j++){
            short valueAsShort = (short)( (convert[i] << 8)  | (convert[i+1] & 0xff));
            float valueAsFloat = (float)valueAsShort;
            System.out.println(valueAsFloat);
            valueAsFloat = data[j];
            System.out.println(data[j]);
        }can anyone see anythign wrong with the way I am doing this? I cant see anythign wrong but need to make sure its fine before I can continue.
    any advice on this or a better way to do it would be much appreciated.

    ultiron wrote:
    I'm pretty sure they do. The way im doing it is by taking 2 byte values and changing them to a 16 bit float.
    the way the bytes are shift they should only take up 16 bits.It's not that simple.
    First, a float in Java is always 4 bytes. The fact that it has an integer value that can fit into two bytes is irrelevant
    Second, floating point representation is not the same 2s complement that's used for byte, short, int, and long, so you're not just shifting the bits.
    For eample:
    1,  int: 00000000 00000000 00000000 00000001
    1, float: 00111111 10000000 00000000 00000000
    -1,  int: 11111111 11111111 11111111 11111111
    -1, float: 10111111 10000000 00000000 00000000Having said that, you're casting, so your step of going from short to float is correct. It doesn't just shift; it does conversions like the above. The caveats are:
    1) Is your conversion from bytes to short correct? That depends on what those bytes are supposed to be. If they're big-endian representations of 2-byte, 2s-complement numbers, then your code looks correct. You'll still have to test it of course. You'll want to focus on corner cases.
    00 00 --> 0
    00 01 --> 1
    10 00 --> 4096
    7f ff --> 32767
    80 00 --> -32768
    ff ff --> -1
    2) Can float hold all of short's values? I think it can. It obviously can't hold all of int's values, but I think it's precision is sufficient to cover short.
    By the way, is there a reason you're using float instead of double? Unless you're in an extremely memory-constrained environment, there's no reason to use double.

  • Converting byte[] to float the value become NaN even there is value existing.

    I tried from the online Sample but,  
                        Array.Reverse(data, index * 4, 4);
                        result = BitConverter.ToSingle(data, index * 4);
    When the  condition  index*4>data.length it will through exception.
    Thanks,

    Hi sasikumar.93,
    In C# the NAN is related to this:
    https://msdn.microsoft.com/en-us/library/system.double.nan(v=vs.110).aspx and also
    https://msdn.microsoft.com/en-us/library/system.single.nan.aspx
    Maybe the convert here becomes NaN field which raised the exception.
    Best regards,
    Barry
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • The TCP/IP Write Function is transmitting Hex data as ASCII; E.g. 5 bytes of Hex (010518001E)and TCP/IP transmits 10 bytes in ASCII(30 31 30 35 31 38 30 30 31 45).

    Our TCP/IP Server sent a 8 binary bytes (a float number) and from our TCP/IP Client, we try to convert it back into a float number ... but failed. We did try to use the same sample in com./TCP/IP also use type cast but failed the same! Some one can help us? Thanks
    Attachments:
    Test_TCP_IP.vi ‏45 KB

    Sorry guys, It is me ATC ... by mistakes the I did post with wrong title messages! Please ignore the title ... read the detail & attachement!
    Thanks for understanding (I could not remove my post questions)

  • How to read binary file into a 2D float array??

    Hi All,
    I really need help to get this one as I am stuck and can't seem to find any way out of it. I am given a '.dat' file that has float values in it. I want to read this file in java and put it in a 2D float array. The file has basically a matrix of float values. What I want to do is to read this binary file and put all its data into 2D float array (float [] []) so that I can use it in my program. Is there a way to read file like this? I did find a similar matlab code (below) but cant seem to find anything in java and i really want to do this in java only.. I will appreciate ur help in this one.
    thanks very much
    Nitya
    fid = fopen('datafile.dat');
    A = fread(fid,[50 50],'float32');
    fclose(fid);

    I shud have shown the two ways that i Already tried. here they are..
    first one using DataInputStream and then trying to readFloat()
    DataInputStream dis = ....
    Float f = dis.readFloat();This code gives code gives me some random values like this.. (i had a loop)
    5.8758974E-14
    -0.41055492
    1.5724557E-30
    1.06822824E14
    -1.91934371E15
    3.43829601E13
    Other way i tried was this.. which seems right but here i have to convert byte to float and i thnk that code is giving some different results (slightly different float values) not sure why....may be my indexing of the array is wrong to make it a matrix.. or something else...
    is.read(bytes, offset....);
    int cnt = 0;
    int j = 0;
    for (int start = 0; start < offset; start = start + 4) {
      if(j<50){
           myarray[cnt][j] = this.arr2float(bytes, start);
             System.out.println(cnt + "-" + j + " = " + myarray[cnt][j]);
           j++;
    }else{
      if(cnt < 50){
           cnt++;
           j = 0;
      }else{
           break;
    public float arr2float (byte[] arr, int start) {
              int i = 0;
              int len = 4;
              int cnt = 0;
              byte[] tmp = new byte[len];
              for (i = start; i < (start + len); i++) {
                   tmp[cnt] = arr;
                   cnt++;
              int accum = 0;
              i = 0;
              for ( int shiftBy = 0; shiftBy < 32; shiftBy += 8 ) {
                   accum |= ( (long)( tmp[i] & 0xff ) ) << shiftBy;
                   i++;
              return Float.intBitsToFloat(accum);
    Not sure if i am missing some other way to do this...                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Need help w corba/jdbc class

    hi
    i'm trying to get this class to work right, i don't think i'm coding it the right way, especially the getAllAccounts() and selectAccounts() methods. this code compiles cleanly, but i get runtime exceptions when i try to run my app. my runtime exceptions look like
    ############################ StackTrace ############################
    java.lang.NullPointerException
    at com.kafein.accountServices.AccountServiceImpl.getAllAccounts(AccountS
    erviceImpl.java:218)
    at com.kafein.idl.accountServices.AccountServicePOA._invoke(AccountServi
    cePOA.java:74)
    at org.jacorb.poa.RequestProcessor.invokeOperation(RequestProcessor.java
    :247)
    at org.jacorb.poa.RequestProcessor.process(RequestProcessor.java:477)
    at org.jacorb.poa.RequestProcessor.run(RequestProcessor.java:604)
    and
    Creating 100 Accounts
    org.omg.CORBA.UNKNOWN: This exception was reported by the server, it is only re-
    thrown here. vmcid: 0x0 minor code: 0 completed: No
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Sou
    rce)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at org.jacorb.orb.SystemExceptionHelper.read(SystemExceptionHelper.java:
    157)
    at org.jacorb.orb.connection.ReplyInputStream.checkExceptions(ReplyInput
    Stream.java:117)
    at org.jacorb.orb.Delegate.invoke(Delegate.java:942)
    at org.omg.CORBA.portable.ObjectImpl._invoke(Unknown Source)
    at com.kafein.idl.accountServices._AccountServiceStub.getAllAccounts(_Ac
    countServiceStub.java:134)
    at com.kafein.client.AccountClient.main(AccountClient.java:111)
    org.omg.CORBA.UNKNOWN: This exception was reported by the server, it is only re-
    thrown here. vmcid: 0x0 minor code: 0 completed: No
    ORB shutting down...
    code for this class is below...
    // AccountServiceImpl.java: The AccountService Implementation
    package com.kafein.accountServices;
    import java.util.Hashtable;
    import java.util.Calendar;
    import java.util.GregorianCalendar;
    import junit.framework.TestCase;
    import junit.framework.Test;
    import junit.framework.TestSuite;
    import org.omg.PortableServer.*;
    import com.kafein.idl.accountServices.AccountServicePOA;
    import com.kafein.idl.accountServices.AccountEntryStruct;
    import com.kafein.idl.accountServices.AccountStruct;
    import com.kafein.idl.utilities.DateTimeStruct;
    import com.kafein.idl.exceptions.NotFoundException;
    import com.kafein.idl.exceptions.DataValidationException;
    import com.kafein.idl.errorCodes.DataValidationErrorCodes;
    import com.kafein.utils.ServiceHandler;
    import com.kafein.utils.Log;
    import java.net.URL;
    import java.sql.*;
    import java.util.*;
    * AccountServiceImpl is an implementation of the
    * idl.accountServices.AccountService interface.
    public class AccountServiceImpl extends AccountServicePOA {
      POA poa;
      private Hashtable accounts = new Hashtable(); // collection of Accounts
      private static int nextAccountID = 1; // global account ID
      Connection connection;
      Vector connections;
      Statement statement;
      PreparedStatement preparedStatement;
       * Construct an instance.
      public AccountServiceImpl(POA aPOA, String driver, String url, String user, String password) {
        super();
        poa = aPOA;
        driver = driver;
        url = url;
        user = user;
        password = password;
        connections = new Vector();
        // Connect to Database
        try {
            connect(driver,url,user,password);
        catch(Exception e) {
               e.printStackTrace();       
        // Simple Database Select
        try {
            testSimpleSelect();
        catch(Exception e) {
               e.printStackTrace();       
        // Database Select
        try {
            testSelect();
        catch(Exception e) {
               e.printStackTrace();       
       * Overloaded constructor for unit tests.
      protected AccountServiceImpl() {
        poa = null;
       * createAccount is used by administrator to add a new Account
       * in the system.
       * @param newAccount AccountEntryStruct containing data for new account
       * @return int the new unique Account ID
       * @exception com.kafein.idl.exceptions.DataValidationException
      public int createAccount(AccountEntryStruct newAccount) throws
        DataValidationException {
        validateData (newAccount); // throws DataValidationException;
        int accountID = getNextID();     
        // Create new Account.
        Account anAccount = new Account(accountID,
                            newAccount.userName,
                            newAccount.userEmail,
                            newAccount.creditCardType,
                            newAccount.creditCardNumber,
                            newAccount.creditCardExpirationDate.year,
                            newAccount.creditCardExpirationDate.month,
                            newAccount.userPassword,
                            newAccount.initialBalance);
    // Insert here / call method insertAccount() pass it in an account object
    // or call manager object - accountmanager.put()
        // Insert Account into Database
        try {
            insertAccount(anAccount);
        catch(Exception e) {
               e.printStackTrace();       
        accounts.put(accountID,anAccount);
        return accountID;
       * isAccountValid is used to validate a user logon.
       * @param accountID AccountID
       * @param userPassword String
       * @return boolean true to indicate an existing Account
      public boolean isValidAccount (int accountID, String userPassword) {
        // Get account with key equal to accountID.
        AccountStruct anAccount;
        try {
          anAccount = (AccountStruct) getAccount (accountID);
        catch (NotFoundException e) {
          return false;
        // Verify password.
        return (anAccount.userPassword.equals(userPassword) ? true : false);
       * getAccount is used to retrieve an existing Account in the system
       * @param int AccountID
       * @return AccountStruct containing data for the existing Account
       * @exception com.kafein.idl.exceptions.NotFoundException
      public AccountStruct getAccount(int accountID)throws
        NotFoundException {
        // Verify that accountID is within an appropriate interval.
        if (accountID < 1 || accountID > accounts.size()) {
          throw new NotFoundException(DataValidationErrorCodes.INVALID_ACCOUNT_ID,
                          "Account ID not found");
        // Get Account and convert to AccountStruct (which is returned).
        Account anAccount = (Account) accounts.get(accountID);
        return anAccount.getAccountStruct();
       * getAllAccounts is used to retrieve all existing Accounts in the system
       * @return AccountStruct[] containing all existing Accounts.
       * @fyi returns an empty sequence if no Accounts exist
      // GetAllAcounts method v. 2 - rather than enumerating through the vector
      // call a method that returns a collection of objs in that method where
      // you do select stmts
      public AccountStruct[] getAllAccounts() {
        // Allocate the array of AccountStructs.
        Vector results = new Vector();
        try {
                results = selectAccounts();
        catch(Exception e) {
               e.printStackTrace();       
        //Vector results = selectAccounts();
        int lastKey = results.size();
        //int lastKey = accounts.size();
        AccountStruct[] accountSequence = new AccountStruct[lastKey];
        if (lastKey==0) {
          return accountSequence;
        // Create AccountStructs from Accounts.
        for (int i = 1; i <= lastKey; i++) {
          Account anAccount = (Account) accounts.get(i);
          accountSequence[i-1] = anAccount.getAccountStruct();
        return accountSequence;
       * validateData is used to check new account data.
       * @param newAccount AccountEntryStruct containing data for new account
       * @exception com.kafein.idl.exceptions.DataValidationException
      protected void validateData(AccountEntryStruct newAccount) throws
        DataValidationException {
        // Check all of the member data in newAccount.
        if (newAccount.userName.equals("")) {
          throw new DataValidationException(
              DataValidationErrorCodes.INVALID_USER_NAME,
              "User Name must not be empty");
        if (newAccount.userEmail.equals("")) {
          throw new DataValidationException(
              DataValidationErrorCodes.INVALID_USER_EMAIL,
              "User Email must not be empty");
        if (newAccount.creditCardType.equals("")) {
          throw new DataValidationException(
              DataValidationErrorCodes.INVALID_CREDIT_CARD_TYPE,
              "Credit card type must not be empty");
        if (newAccount.creditCardNumber.equals("")) {
          throw new DataValidationException(
              DataValidationErrorCodes.INVALID_CREDIT_CARD_NUMBER,
              "Credit card number must not be empty");
        // Compare creditCardExpirationDate to current date
        // (we only consider year and month).
        GregorianCalendar now = new GregorianCalendar();
        DateTimeStruct proposed = newAccount.creditCardExpirationDate;
        if (proposed.year < now.get (Calendar.YEAR) ||
         (proposed.year == now.get (Calendar.YEAR) &&
          proposed.month < now.get (Calendar.MONTH) + 1)) {
          throw new DataValidationException(
              DataValidationErrorCodes.INVALID_CREDIT_CARD_EXPIRATION_DATE,
              "Credit card has expired");
        if (newAccount.userPassword.equals("")) {
          throw new DataValidationException(
              DataValidationErrorCodes.INVALID_USER_PASSWORD,
              "Password must not be empty");
        else if (!newAccount.userPassword.equals(newAccount.userPasswordVerification)) {
          throw new DataValidationException(
              DataValidationErrorCodes.INVALID_USER_PASSWORD,
              "Password verification failure");
        if (newAccount.initialBalance < 0.0F) {
          throw new DataValidationException(
              DataValidationErrorCodes.INVALID_BALANCE,
              "Account Balance cannot have a negative balance");
       * getNextID is used to generate a unique ID.
       * Needs a much better implementation that generates a globally unique ID!
       * @return int an Account ID
      protected synchronized int getNextID() {
        nextAccountID++;
        return nextAccountID - 1;
       * override _default_POA to return this servant's POA, not Root POA
      public POA _default_POA() {
        return poa;
       * jdbc related methods
      public void connect(String driver, String url, String user, String password)
                    throws Exception {
            try {
                // Load JDBC driver
                Class.forName(driver);
                System.out.println("Connecting to " + url);
                connection = DriverManager.getConnection(url, user, password);
                connections.add(connection);
                connection.setAutoCommit(false);
            } catch(Exception e) {
                System.err.println("System Exception in connect");
                System.err.println(e);
                throw e;
      public void closeConnection() throws Exception {
            try {
                Enumeration myEnum = connections.elements();
                while ( myEnum.hasMoreElements() ) {
                    System.out.println("Closing connection");
                    ((Connection) myEnum.nextElement()).close();
            } catch (Exception e) {
                System.err.println("System Exception in closeConnection");
                System.err.println(e);
                throw e;
      private void testSimpleSelect() throws Exception {
            try {
                Statement statement = connection.createStatement();
                ResultSet rs = statement.executeQuery("Select 1 from ACCOUNT");
                if (rs != null && rs.next()) {
                   int value = rs.getInt(1);
                   System.out.println("Fetched value " + value);
                connection.commit();
                statement.close();
            } catch(Exception e) {
                System.err.println("System Exception in testSimpleSelect");
                System.err.println(e);
                throw e;
      private void testSelect() throws Exception {
            try {
                Statement statement = connection.createStatement();
                ResultSet rs = statement.executeQuery(
                    "Select ACCT_ID, ACCT_USERNAME, ACCT_USEREMAIL, ACCT_CC_TYPE, ACCT_CC_NUMBER, ACCT_CC_EXPYR, ACCT_CC_EXPMO, ACCT_USERPASSWORD, ACCT_USERBALANCE from ACCOUNT LIMIT 1");
                System.out.println("Account ID   User Name     User Email     CC Type     CC Number     CC Expyr CC Expmo User Password     User Balance");
                while (rs != null && rs.next()) {
                    int acct_id = rs.getInt(1);
                    String acct_username = rs.getString(2);
                    String acct_useremail = rs.getString(3);
                    String acct_cc_type = rs.getString(4);
                    String acct_cc_number = rs.getString(5);
                    int acct_cc_expyr = rs.getInt(6);
                    int acct_cc_expmo = rs.getInt(7);
                    String acct_userpassword = rs.getString(8);
                    float acct_userbalance = rs.getFloat(9);
                    System.out.println(acct_id + "         " +
                                       acct_username + "   " +
                                       acct_useremail + "   " +
                                       acct_cc_type + "   " +
                                       acct_cc_number + "   " +
                                       acct_cc_expyr + "   " +
                                       acct_cc_expmo + "   " +
                                       acct_userpassword + "   " +
                                       acct_userbalance);
                connection.commit();
                statement.close();
            } catch(Exception e) {
                System.err.println("System Exception in testSelect");
                System.err.println(e);
                throw e;
      private void testLoadData() throws Exception {
            int numberOfAccounts = 5;
            String  acct_username    = "<--20 BYTE STRING-->";
            String  acct_useremail = "<--20 BYTE STRING-->";
         String  acct_cc_type = "TEST ";
            String  acct_cc_number = "<--20 BYTE STRING-->";
            int  acct_cc_expyr = 2000;
            int  acct_cc_expmo = 1;
            String  acct_userpassword = "<--20 BYTE STRING-->";
            float     acct_userbalance = 0.0F;
            int     acct_id = 0;
         try {
                System.out.println("Inserting data...");
                connection.setAutoCommit(false);
                // Calculate Start time
                System.out.println("Starting data insertion (" + numberOfAccounts +
                    " rows) into ACCOUNT table..");
                long startTime = System.currentTimeMillis();
                preparedStatement = connection.prepareStatement(
                    "INSERT INTO ACCOUNT (ACCT_ID, ACCT_USERNAME, ACCT_USEREMAIL, ACCT_CC_TYPE, ACCT_CC_NUMBER, " +
                    "ACCT_CC_EXPYR, ACCT_CC_EXPMO, ACCT_USERPASSWORD, ACCT_USERBALANCE) VALUES ( ?, ?, ?, ?, ?, ? , ?, ?, ?)");
                // Insert accounts in ACCOUNT table
                for (int i = 1; i <= numberOfAccounts; i++) {
                    acct_id  = i * 1000;
                    preparedStatement.setInt(1, acct_id);
                    preparedStatement.setString(2, acct_username);
                    preparedStatement.setString(3, acct_useremail);
                    preparedStatement.setString(4, acct_cc_type);
                    preparedStatement.setString(5, acct_cc_number);
                    preparedStatement.setInt(6, acct_cc_expyr);
                    preparedStatement.setInt(7, acct_cc_expmo);
                    preparedStatement.setString(8, acct_userpassword);
                    preparedStatement.setFloat(9, acct_userbalance);
              preparedStatement.executeUpdate();
                    connection.commit();
                System.out.println(numberOfAccounts + " accounts created.");
                preparedStatement.close();
                long stopTime = System.currentTimeMillis();
                System.out.println("Account table load complete.");
                System.out.println("Load time = " +
                                   ((stopTime - startTime)/(1000f)) + " seconds");
                System.out.println("Data insertion complete");
            } catch(Exception e) {
                System.err.println("System Exception in loadData");
                System.err.println(e);
                throw e;
       * insertAccount is used to insert a new Account in the Database
       * @param int AccountID
       * @return AccountStruct containing data for the existing Account
      private void insertAccount(Account anAccount) throws Exception {
              AccountStruct anAccountStruct = anAccount.getAccountStruct();  
         int numberOfAccounts = 1;
         String  acct_username    = anAccountStruct.userName;
            String  acct_useremail = anAccountStruct.userEmail;
         String  acct_cc_type = anAccountStruct.creditCardType;
            String  acct_cc_number = anAccountStruct.creditCardNumber;
         int acct_cc_expyr = anAccountStruct.creditCardExpirationDate.year;
            int acct_cc_expmo = anAccountStruct.creditCardExpirationDate.month;
            String  acct_userpassword = anAccountStruct.userPassword;
            float     acct_userbalance = anAccountStruct.accountBalance;
            int     acct_id = anAccountStruct.accountID;
         try {
                System.out.println("Inserting data...");
                connection.setAutoCommit(false);
    //instead of system.out just log
                // Calculate Start time
                System.out.println("Starting data insertion ( 1" +
                    " row) into ACCOUNT table..");
                long startTime = System.currentTimeMillis();
                preparedStatement = connection.prepareStatement(
                    "INSERT INTO ACCOUNT (ACCT_ID, ACCT_USERNAME, ACCT_USEREMAIL, ACCT_CC_TYPE, ACCT_CC_NUMBER, " +
                    "ACCT_CC_EXPYR, ACCT_CC_EXPMO, ACCT_USERPASSWORD, ACCT_USERBALANCE) VALUES ( ?, ?, ?, ?, ?, ? , ?, ?, ?)");
                    acct_id  = 1000;
                    preparedStatement.setInt(1, acct_id);
                    preparedStatement.setString(2, acct_username);
                    preparedStatement.setString(3, acct_useremail);
                    preparedStatement.setString(4, acct_cc_type);
                    preparedStatement.setString(5, acct_cc_number);
                    preparedStatement.setInt(6, acct_cc_expyr);
                    preparedStatement.setInt(7, acct_cc_expmo);
                    preparedStatement.setString(8, acct_userpassword);
                    preparedStatement.setFloat(9, acct_userbalance);
              preparedStatement.executeUpdate();
                    connection.commit();
                System.out.println("1 account created.");
                preparedStatement.close();
                long stopTime = System.currentTimeMillis();
                System.out.println("Account table load complete.");
                System.out.println("Load time = " +
                                   ((stopTime - startTime)/(1000f)) + " seconds");
                System.out.println("Data insertion complete");
            } catch(Exception e) {
                System.err.println("System Exception in loadData");
                System.err.println(e);
                throw e;
      private Vector selectAccounts() throws Exception {
            try {
                // Create Vector to hold individual Account values
             Vector mainvector = new Vector();
             Vector values = new Vector();
             Statement statement = connection.createStatement();
                ResultSet rs = statement.executeQuery(
                    "Select ACCT_ID, ACCT_USERNAME, ACCT_USEREMAIL, ACCT_CC_TYPE, ACCT_CC_NUMBER, ACCT_CC_EXPYR, ACCT_CC_EXPMO, ACCT_USERPASSWORD, ACCT_USERBALANCE from ACCOUNT");
                System.out.println("Account ID   User Name     User Email     CC Type     CC Number     CC Expyr CC Expmo User Password     User Balance");
             // Iterate through result set
             while (rs != null && rs.next()) {
              // Make sure values is empty
              values.clear();
              int acct_id = rs.getInt(1);
                    String acct_username = rs.getString(2);
                    String acct_useremail = rs.getString(3);
                    String acct_cc_type = rs.getString(4);
                    String acct_cc_number = rs.getString(5);
                    int acct_cc_expyr = rs.getInt(6);
                    int acct_cc_expmo = rs.getInt(7);
                    String acct_userpassword = rs.getString(8);
                    float acct_userbalance = rs.getFloat(9);
              // Populate Vector values
              values.addElement(rs.getObject(1));
              values.addElement(rs.getObject(2));
              values.addElement(rs.getObject(3));
              values.addElement(rs.getObject(4));
              values.addElement(rs.getObject(5));
              values.addElement(rs.getObject(6));
              values.addElement(rs.getObject(7));
              values.addElement(rs.getObject(8));
              values.addElement(rs.getObject(9));
              mainvector.addElement(values);
                    System.out.println(acct_id + "         " +
                                       acct_username + "   " +
                                       acct_useremail + "   " +
                                       acct_cc_type + "   " +
                                       acct_cc_number + "   " +
                                       acct_cc_expyr + "   " +
                                       acct_cc_expmo + "   " +
                                       acct_userpassword + "   " +
                                       acct_userbalance);
                connection.commit();
                statement.close();
             return mainvector;
            } catch(Exception e) {
                System.err.println("System Exception in selectAccounts");
                System.err.println(e);
                throw e;
        }

    line 217 and 218 is
    Account anAccount = (Account) accounts.get(i);
    accountSequence[i-1] = anAccount.getAccountStruct();
    i realized that
    Account anAccount = (Account) accounts.get(i);
    was a typo. what it should have been was
    Account anAccount = (Account) results.get(i);
    so my getAllAccounts() method now looks like
       * getAllAccounts is used to retrieve all existing Accounts in the system
       * @return AccountStruct[] containing all existing Accounts.
       * @fyi returns an empty sequence if no Accounts exist
      // GetAllAcounts method v. 2 - rather than enumerating through the vector
      // call a method that returns a collection of objs in that method where
      // you do select stmts
      public AccountStruct[] getAllAccounts() {
        // Allocate the array of AccountStructs.
        Vector results = new Vector();
        try {
                results = selectAccounts();
        catch(Exception e) {
               e.printStackTrace();       
        //Vector results = selectAccounts();
        int lastKey = results.size();
        //int lastKey = accounts.size();
        AccountStruct[] accountSequence = new AccountStruct[lastKey];
        if (lastKey==0) {
          return accountSequence;
        // Create AccountStructs from Accounts.
        for (int i = 1; i <= lastKey; i++) {
          Account anAccount = (Account) results.get(i);
          accountSequence[i-1] = anAccount.however, i still get the same runtime errors.
    is my selectAccounts() method returning a null?

  • USB wifi adapter can only handle one request or socket at a time

    I have a usb wifi adapter that I bought recently.  The strange thing is that if I'm doing only one thing that is using the network (e.g. downloading a file) it works good and fast. But say I'm downloading a file and I do ANYTHING else that uses the network (e.g. just opening a browser at google.ca), the download comes to a stop. Then if I close the browser, the download starts up again a couple seconds later, good and fast.
    Another example is, say I'm in a Google Hangouts (video chat) session. As long as that is the only thing I have running, the chat works fine. If I open a second browser window, then the chat gets super choppy and pretty much un-usable until I close the second window.
    So basically it seems like I can have only one open socket at a time, or else it can handle only one request at a time. Also, most webpages open very slowly as a result because the browser only seems to be able to download one static file at a time (e.g. js and css files needed by the page).
    I'm sure it's a problem with the usb wifi adapter because I didn't have these problems when I was on a wired connection, and I have other devices using wifi (e.g. laptops and tablets) that don't have this problem either.
    Rather than paste a bunch of output from commands, please kindly tell me what to run in order to gather any useful info.
    Thanks,
    Edit:  The adapter is an ASUS USB n-53 (N600).
    Last edited by Pacopag (2014-07-18 14:36:20)

    I was exploring the CD that came with the device.  Turns out there are Linux drivers on it.  I didn't install any drivers, as wicd detected it automatically.  I'm wondering if changing drivers might help.  Can someone help me interpret the installation instructions?
    Here are the instructions
    * README
    * Ralink Tech Inc.
    * http://www.ralinktech.com
    =======================================================================
    ModelName:
    ===========
    RT3572 Wireless Lan Linux Driver
    =======================================================================
    Driver lName:
    ===========
    rt3572sta.o/rt3572sta.ko
    =======================================================================
    Supporting Kernel:
    ===================
    linux kernel 2.4 and 2.6 series.
    Tested in Redhat 7.3 or later.
    =======================================================================
    Ralink Hardware:
    ===================
    Ralink 802.11n Wireless LAN Card.
    =======================================================================
    Description:
    =============
    This is a linux device driver for Ralink RT2870 USB ABGN WLAN Card.
    =======================================================================
    Contents:
    =============
    Makefile : Makefile
    *.c : c files
    *.h : header files
    =======================================================================
    Features:
    ==========
    This driver implements basic IEEE802.11. Infrastructure and adhoc mode with
    open or shared or WPA-PSK or WPA2-PSK authentication method.
    NONE, WEP, TKIP and AES encryption.
    =======================================================================
    Build Instructions:
    ====================
    1> tar -jxvf 2011_1003_RT3572_Linux_STA_v2.5.0.0.DPO.tar.bz2
    go to "./2011_1003_RT3572_Linux_STA_v2.5.0.0.DPO" directory.
    2> switch to super user.
    ** for Fedora
    $su
    ** for Ubuntu
    $sudo su
    3> in Makefile
    set the "MODE = STA" in Makefile and chose the TARGET to Linux by set "TARGET = LINUX"
    define the linux kernel source include file path LINUX_SRC
    modify to meet your need.
    4> in os/linux/config.mk
    define the GCC and LD of the target machine
    define the compiler flags CFLAGS
    modify to meet your need.
    ** Build for being controlled by NetworkManager or wpa_supplicant wext functions
    Please set 'HAS_WPA_SUPPLICANT=y' and 'HAS_NATIVE_WPA_SUPPLICANT_SUPPORT=y'.
    => #>cd wpa_supplicant-x.x
    => #>./wpa_supplicant -Dwext -ira0 -c wpa_supplicant.conf -d
    ** Build for being controlled by WpaSupplicant with Ralink Driver
    Please set 'HAS_WPA_SUPPLICANT=y' and 'HAS_NATIVE_WPA_SUPPLICANT_SUPPORT=n'.
    => #>cd wpa_supplicant-0.5.7
    => #>./wpa_supplicant -Dralink -ira0 -c wpa_supplicant.conf -d
    5> compile driver source code
    $make
    =======================================================================
    Install Instructions:
    ================================
    1> load driver
    $make install
    2> plug in USB dongle.
    =======================================================================
    Note:
    ================================
    Under Fedora 15 or 16, after you install the driver, if there is "firmware missing" issue occurs, please follow the following steps:
    1> remove driver
    $rmmod rt2800usb
    $rmmod rt2800lib
    $rmmod rt2x00usb
    $rmmod rt2x00lib
    2> enter /etc/modprobe.d and edit blacklist.conf. Add one line (ususally add it in the buttom of the file):
    blacklist rt2800usb
    3> reboot system
    $reboot
    =======================================================================
    Uninstall Instructions:
    ================================
    1> go to "./2011_1003_RT3572_Linux_STA_v2.5.0.0.DPO" directory.
    2> switch to super user.
    $sudo su
    3> unload driver
    $make uninstall
    4> reboot system
    $reboot
    =======================================================================
    CONFIGURATION:
    ====================
    RT2870 driver can be configured via following interfaces,
    i.e. (i)"iwconfig" command, (ii)"iwpriv" command, (iii) configuration file
    i) iwconfig comes with kernel.
    ii) iwpriv usage, please refer to file "iwpriv_usage.txt" for details.
    iii)modify configuration file "RT2870STA.dat" in /etc/Wireless/RT2870STA/RT2870STA.dat.
    Configuration File : RT2870STA.dat
    # Copy this file to /etc/Wireless/RT2870STA/RT2870STA.dat
    # This file is a binary file and will be read on loading rt.o module.
    # Use "vi RT2870STA.dat" to modify settings according to your need.
    # 1.) set NetworkType to "Adhoc" for using Adhoc-mode, otherwise using Infrastructure
    # 2.) set Channel to "0" for auto-select on Infrastructure mode
    # 3.) set SSID for connecting to your Accss-point.
    # 4.) AuthMode can be "WEPAUTO", "OPEN", "SHARED", "WPAPSK", "WPA2PSK", "WPANONE"
    # 5.) EncrypType can be "NONE", "WEP", "TKIP", "AES"
    # for more information refer to the Readme file.
    #The word of "Default" must not be removed
    Default
    CountryRegion=5
    CountryRegionABand=7
    CountryCode=
    SSID=Dennis2860AP
    NetworkType=Infra
    WirelessMode=9
    Channel=0
    BeaconPeriod=100
    TxPower=100
    BGProtection=0
    TxPreamble=0
    RTSThreshold=2347
    FragThreshold=2346
    TxBurst=1
    WmmCapable=0
    AckPolicy=0;0;0;0
    AuthMode=OPEN
    EncrypType=NONE
    WPAPSK=
    DefaultKeyID=1
    Key1Type=0
    Key1Str=
    Key2Type=0
    Key2Str=
    Key3Type=0
    Key3Str=
    Key4Type=0
    Key4Str=
    PSMode=CAM
    FastRoaming=0
    RoamThreshold=70
    HT_RDG=1
    HT_EXTCHA=0
    HT_OpMode=1
    HT_MpduDensity=4
    HT_BW=1
    HT_AutoBA=1
    HT_BADecline=0
    HT_AMSDU=0
    HT_BAWinSize=64
    HT_GI=1
    HT_MCS=33
    HT_MIMOPSMode=3
    IEEE80211H=0
    TGnWifiTest=0
    WirelessEvent=0
    CarrierDetect=0
    *NOTE:
    WMM parameters
    WmmCapable Set it as 1 to turn on WMM Qos support
    AckPolicy1~4 Ack policy which support normal Ack or no Ack
    (AC_BK, AC_BE, AC_VI, AC_VO)
    All WMM parameters do not support iwpriv command but ¡¥WmmCapable¡¦¡¦,
    please store all parameter to RT2870STA.dat, and restart driver.
    syntax is 'Param'='Value' and describes below.
    @> CountryRegion=value
    value
    0: use 1 ~ 11 Channel
    1: use 1 ~ 13 Channel
    2: use 10 ~ 11 Channel
    3: use 10 ~ 13 Channel
    4: use 14 Channel
    5: use 1 ~ 14 Channel
    6: use 3 ~ 9 Channel
    7: use 5 ~ 13 Channel
    31: use 1 ~ 14 Channel (ch1-11:active scan, ch12-14 passive scan)
    @> CountryRegionABand=value
    value
    0: use 36, 40, 44, 48, 52, 56, 60, 64, 149, 153, 157, 161, 165 Channel
    1: use 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140 Channel
    2: use 36, 40, 44, 48, 52, 56, 60, 64 Channel
    3: use 52, 56, 60, 64, 149, 153, 157, 161 Channel
    4: use 149, 153, 157, 161, 165 Channel
    5: use 149, 153, 157, 161 Channel
    6: use 36, 40, 44, 48 Channel
    7: use 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165 Channel
    8: use 52, 56, 60, 64 Channel
    9: use 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140, 149, 153, 157, 161, 165 Channel
    10: use 36, 40, 44, 48, 149, 153, 157, 161, 165 Channel
    11: use 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 149, 153, 157, 161 Channel
    @> CountryCode=value
    value
    AG, AR, AW, AU, AT, BS, BB, BM, BR, BE, BG, CA, KY, CL, CN, CO, CR, CY, CZ, DK, DO, EC, SV, FI, FR, DE,
    GR, GU, GT, HT, HN, HK, HU, IS, IN, ID, IE, IL, IT, JP, JO, LV, LI, LT, LU, MY, MT, MA, MX, NL, NZ, NO,
    PE, PT, PL, RO, RU, SA, CS, SG, SK, SI, ZA, KR, ES, SE, CH, TW, TR, GB, UA, AE, US, VE
    "" => using default setting: 2.4 G - ch 1~11; 5G - ch 52~64, 100~140, 149~165
    @> SSID=value
    value
    0~z, 1~32 ascii characters.
    @> WirelessMode=value
    value
    0: legacy 11b/g mixed
    1: legacy 11B only
    2: legacy 11A only //Not support in RfIcType=1(id=RFIC_5225) and RfIcType=2(id=RFIC_5325)
    3: legacy 11a/b/g mixed //Not support in RfIcType=1(id=RFIC_5225) and RfIcType=2(id=RFIC_5325)
    4: legacy 11G only
    5: 11ABGN mixed
    6: 11N only
    7: 11GN mixed
    8: 11AN mixed
    9: 11BGN mixed
    10: 11AGN mixed
    @> Channel=value
    value
    depends on CountryRegion or CountryRegionABand
    @> BGProtection=value
    value
    0: Auto
    1: Always on
    2: Always off
    @> TxPreamble=value
    value
    0:Preamble Long
    1:Preamble Short
    2:Auto
    @> RTSThreshold=value
    value
    1~2347
    @> FragThreshold=value
    value
    256~2346
    @> TxBurst=value
    value
    0: Disable
    1: Enable
    @> NetworkType=value
    value
    Infra: infrastructure mode
    Adhoc: adhoc mode
    @> AuthMode=value
    value
    OPEN For open system
    SHARED For shared key system
    WEPAUTO Auto switch between OPEN and SHARED
    WPAPSK For WPA pre-shared key (Infra)
    WPA2PSK For WPA2 pre-shared key (Infra)
    WPANONE For WPA pre-shared key (Adhoc)
    WPA Use WPA-Supplicant
    WPA2 Use WPA-Supplicant
    @> EncrypType=value
    value
    NONE For AuthMode=OPEN
    WEP For AuthMode=OPEN or AuthMode=SHARED
    TKIP For AuthMode=WPAPSK or WPA2PSK
    AES For AuthMode=WPAPSK or WPA2PSK
    @> DefaultKeyID=value
    value
    1~4
    @> Key1=value
    Key2=value
    Key3=value
    Key4=value
    value
    10 or 26 hexadecimal characters eg: 012345678
    5 or 13 ascii characters eg: passd
    (usage : "iwpriv" only)
    @> Key1Type=vaule
    Key2Type=value
    Key3Type=vaule
    Key4Type=vaule
    value
    0 hexadecimal type
    1 assic type
    (usage : reading profile only)
    @> Key1Str=value
    Key2Str=value
    Key3Str=vaule
    Key4Str=vaule
    value
    10 or 26 characters (key type=0)
    5 or 13 characters (key type=1)
    (usage : reading profile only)
    @> WPAPSK=value
    value
    8~63 ASCII or
    64 HEX characters
    @> WmmCapable=value
    value
    0: Disable WMM
    1: Enable WMM
    @> PSMode=value
    value
    CAM Constantly Awake Mode
    Max_PSP Max Power Savings
    Fast_PSP Power Save Mode
    @> FastRoaming=value
    value
    0 Disabled
    1 Enabled
    @> RoamThreshold=value
    value
    Positive Interger(dBm)
    @> HT_RDG=value
    value
    0 Disabled
    1 Enabled
    @> HT_EXTCHA=value (Extended Channel Switch Announcement)
    value
    0 Below
    1 Above
    @> HT_OpMode=value
    value
    0 HT mixed format
    1 HT greenfield format
    @> HT_MpduDensity=value
    value (based on 802.11n D2.0)
    0: no restriction
    1: 1/4 £gs
    2: 1/2 £gs
    3: 1 £gs
    4: 2 £gs
    5: 4 £gs
    6: 8 £gs
    7: 16 £gs
    @> HT_BW=value
    value
    0 20MHz
    1 40MHz
    @> HT_AutoBA=value
    value
    0 Disabled
    1 Enabled
    @> HT_BADecline
    value
    0 Disabled
    1 Enabled <Reject BA request from AP>
    @> HT_AMSDU=value
    value
    0 Disabled
    1 Enabled
    @> HT_BAWinSize=value
    value
    1 ~ 64
    @> HT_GI=value
    value
    0 long GI
    1 short GI
    @> HT_MCS=value
    value
    0 ~ 15
    33: auto
    @> HT_MIMOPSMode=value
    value (based on 802.11n D2.0)
    0 Static SM Power Save Mode
    1 Dynamic SM Power Save Mode
    2 Reserved
    3 SM enabled
    (not fully support yet)
    @> IEEE80211H=value
    value
    0 Disabled
    1 Enabled
    @> TGnWifiTest=value
    value
    0 Disabled
    1 Enabled
    @> WirelessEvent=value
    value
    0 Disabled
    1 Enabled <send custom wireless event>
    @> CarrierDetect=value
    value
    0 Disabled
    1 Enabled
    MORE INFORMATION
    =================================================================================
    If you want for rt2870 driver to auto-load at boot time:
    A) choose ra0 for first RT2870 WLAN card, ra1 for second RT2870 WLAN card, etc.
    B) create(edit) 'ifcfg-ra0' file in /etc/sysconfig/network-scripts/,
    edit( or add the line) in /etc/modules.conf:
    alias ra0 rt2870sta
    C) edit(create) the file /etc/sysconfig/network-scripts/ifcfg-ra0
    DEVICE='ra0'
    ONBOOT='yes'
    NOTE:
    if you use dhcp, add this line too .
    BOOTPROTO='dhcp'
    *D) To ease the Default Gateway setting,
    add the line
    GATEWAY=x.x.x.x
    in /etc/sysconfig/network
    Here is the Makefile
    RT28xx_MODE = STA
    TARGET = LINUX
    CHIPSET = 3572
    OSABL = NO
    #RT28xx_DIR = home directory of RT28xx source code
    RT28xx_DIR = $(shell pwd)
    RTMP_SRC_DIR = $(RT28xx_DIR)/RT$(CHIPSET)
    #PLATFORM: Target platform
    PLATFORM = PC
    #PLATFORM = 5VT
    #PLATFORM = IKANOS_V160
    #PLATFORM = IKANOS_V180
    #PLATFORM = SIGMA
    #PLATFORM = SIGMA_8622
    #PLATFORM = STAR
    #PLATFORM = IXP
    #PLATFORM = INF_TWINPASS
    #PLATFORM = INF_DANUBE
    #PLATFORM = INF_AR9
    #PLATFORM = INF_VR9
    #PLATFORM = BRCM_6358
    #PLATFORM = INF_AMAZON_SE
    #PLATFORM = CAVM_OCTEON
    #PLATFORM = CMPC
    #PLATFORM = RALINK_2880
    #PLATFORM = RALINK_3052
    #PLATFORM = SMDK
    #PLATFORM = RMI
    #PLATFORM = RMI_64
    #PLATFORM = KODAK_DC
    #PLATFORM = DM6446
    #PLATFORM = FREESCALE8377
    #PLATFORM = BL2348
    #PLATFORM = BLUBB
    #PLATFORM = BLPMP
    #PLATFORM = MT85XX
    #PLATFORM = NXP_TV550
    #PLATFORM = MVL5
    ifeq ($(TARGET),LINUX)
    MAKE = make
    endif
    ifeq ($(PLATFORM),5VT)
    LINUX_SRC = /home/ralink-2860-sdk-5vt-distribution/linux-2.6.17
    CROSS_COMPILE = /opt/crosstool/uClibc_v5te_le_gcc_4_1_1/bin/arm-linux-
    endif
    ifeq ($(PLATFORM),IKANOS_V160)
    LINUX_SRC = /home/sample/projects/LX_2618_RG_5_3_00r4_SRC/linux-2.6.18
    CROSS_COMPILE = mips-linux-
    endif
    ifeq ($(PLATFORM),IKANOS_V180)
    LINUX_SRC = /home/sample/projects/LX_BSP_VX180_5_4_0r1_ALPHA_26DEC07/linux-2.6.18
    CROSS_COMPILE = mips-linux-
    endif
    ifeq ($(PLATFORM),SIGMA)
    LINUX_SRC = /root/sigma/smp86xx_kernel_source_2.7.172.0/linux-2.6.15
    CROSS_COMPILE = /root/sigma/smp86xx_toolchain_2.7.172.0/build_mipsel_nofpu/staging_dir/bin/mipsel-linux-
    endif
    ifeq ($(PLATFORM),SIGMA_8622)
    LINUX_SRC = /home/snowpin/armutils_2.5.120.1/build_arm/linux-2.4.22-em86xx
    CROSS_COMPILE = /home/snowpin/armutils_2.5.120.1/toolchain/bin/arm-elf-
    CROSS_COMPILE_INCLUDE = /home/snowpin/armutils_2.5.120.1/toolchain/lib/gcc-lib/arm-elf/2.95.3
    endif
    ifeq ($(PLATFORM),STAR)
    LINUX_SRC = /opt/star/kernel/linux-2.4.27-star
    CROSS_COMPILE = /opt/star/tools/arm-linux/bin/arm-linux-
    endif
    ifeq ($(PLATFORM),RMI)
    LINUX_SRC = /opt/rmi/1.7.0/linux/src/
    CROSS_COMPILE = /opt/rmi/1.7.0/mipscross/nptl/bin/mips64-unknown-linux-gnu-
    endif
    ifeq ($(PLATFORM),RMI_64)
    LINUX_SRC = /opt/rmi/1.7.0/linux_64/src/
    CROSS_COMPILE = /opt/rmi/1.7.0/mipscross/nptl/bin/mips64-unknown-linux-gnu-
    endif
    ifeq ($(PLATFORM), RALINK_2880)
    LINUX_SRC = /project/stable/RT288x/RT288x_SDK/source/linux-2.4.x
    CROSS_COMPILE = /opt/buildroot-gdb/bin/mipsel-linux-
    endif
    ifeq ($(PLATFORM),RALINK_3052)
    LINUX_SRC = /home/peter/ap_soc/SDK_3_3_0_0/RT288x_SDK/source/linux-2.6.21.x
    CROSS_COMPILE = /opt/buildroot-gcc342/bin/mipsel-linux-uclibc-
    endif
    ifeq ($(PLATFORM),FREESCALE8377)
    LINUX_SRC = /opt/ltib-mpc8377_rds-20090309/rpm/BUILD/linux-2.6.25
    CROSS_COMPILE = /opt/freescale/usr/local/gcc-4.2.187-eglibc-2.5.187/powerpc-linux-gnu/bin/powerpc-linux-gnu-
    endif
    ifeq ($(PLATFORM),BL2348)
    LINUX_SRC = /home/sample/Customers/BroadLight/bl234x-linux-2.6.21-small-v29
    CROSS_COMPILE = mips-wrs-linux-gnu-
    endif
    ifeq ($(PLATFORM),BLUBB)
    LINUX_SRC = /home/sample/Customers/BroadLight/UBB/gmp20/linux-2.6.21-small
    CROSS_COMPILE = mips-wrs-linux-gnu-
    endif
    ifeq ($(PLATFORM),BLPMP)
    LINUX_SRC = /home/sample/Customers/BroadLight/UBB/pmp16/bl234x-linux-2.6.21-small-v30.2
    CROSS_COMPILE = mips-wrs-linux-gnu-
    endif
    ifeq ($(PLATFORM),PC)
    # Linux 2.6
    LINUX_SRC = /lib/modules/$(shell uname -r)/build
    # Linux 2.4 Change to your local setting
    #LINUX_SRC = /usr/src/linux-2.4
    LINUX_SRC_MODULE = /lib/modules/$(shell uname -r)/kernel/drivers/net/wireless/
    CROSS_COMPILE =
    endif
    ifeq ($(PLATFORM),IXP)
    LINUX_SRC = /project/stable/Gmtek/snapgear-uclibc/linux-2.6.x
    CROSS_COMPILE = arm-linux-
    endif
    ifeq ($(PLATFORM),INF_TWINPASS)
    # Linux 2.6
    #LINUX_SRC = /lib/modules/$(shell uname -r)/build
    # Linux 2.4 Change to your local setting
    LINUX_SRC = /project/stable/twinpass/release/2.0.1/source/kernel/opensource/linux-2.4.31/
    CROSS_COMPILE = mips-linux-
    endif
    ifeq ($(PLATFORM),INF_DANUBE)
    LINUX_SRC = /opt/danube/sdk/linux-2.6.16.x
    CROSS_COMPILE = mips-linux-
    ROOTDIR = /opt/danube/sdk
    export ROOTDIR
    endif
    ifeq ($(PLATFORM),INF_AR9)
    LINUX_SRC = /root/ar9/xR9_BSP1.2.2.0/source/kernel/opensource/linux-2.6.20/
    CROSS_COMPILE = /root/ar9/ifx-lxdb26-1.0.2/gcc-3.4.4/toolchain-mips/bin/
    endif
    ifeq ($(PLATFORM),INF_VR9)
    LINUX_SRC = /home/public/lantiq/VR9/UGW-4.2/build_dir/linux-ifxcpe_platform_vr9/linux-2.6.20.19
    CROSS_COMPILE = /home/public/lantiq/VR9/UGW-4.2/staging_dir/toolchain-mips_gcc-3.4.6_uClibc-0.9.29/bin/mips-linux-
    endif
    ifeq ($(PLATFORM),BRCM_6358)
    LINUX_SRC =
    CROSS_COMPILE =
    endif
    ifeq ($(PLATFORM),INF_AMAZON_SE)
    # Linux 2.6
    #LINUX_SRC = /lib/modules/$(shell uname -r)/build
    # Linux 2.4 Change to your local setting
    LINUX_SRC = /backup/ifx/3.6.2.2/source/kernel/opensource/linux-2.4.31
    #CROSS_COMPILE = mips-linux-
    #LINUX_SRC = /project/Infineon/3.6.2.2/source/kernel/opensource/linux-2.4.31
    CROSS_COMPILE = /opt/uclibc-toolchain/ifx-lxdb-1-2-3-external/gcc-3.3.6/toolchain-mips/R0208V35/mips-linux-uclibc/bin/
    endif
    ifeq ($(PLATFORM),ST)
    LINUX_SRC = /opt/STM/STLinux-2.2/devkit/sources/kernel/linux0039
    CROSS_COMPILE = /opt/STM/STLinux-2.2/devkit/sh4/bin/sh4-linux-
    ARCH := sh
    export ARCH
    endif
    ifeq ($(PLATFORM),CAVM_OCTEON)
    OCTEON_ROOT = /usr/local/Cavium_Networks/OCTEON-SDK
    LINUX_SRC = $(OCTEON_ROOT)/linux/kernel_2.6/linux
    CROSS_COMPILE = mips64-octeon-linux-gnu-
    endif
    ifeq ($(PLATFORM),CMPC)
    LINUX_SRC = /opt/fvt_11N_SDK_0807/fvt131x_SDK_11n/linux-2.6.17
    CROSS_COMPILE =
    endif
    ifeq ($(PLATFORM),SMDK)
    LINUX_SRC = /home/bhushan/itcenter/may28/linux-2.6-samsung
    CROSS_COMPILE = /usr/local/arm/4.2.2-eabi/usr/bin/arm-linux-
    endif
    ifeq ($(PLATFORM),KODAK_DC)
    SKD_SRC = C:/SigmaTel/DC1250_SDK_v1-9/sdk
    CROSS_COMPILE = $(cc)
    endif
    ifeq ($(PLATFORM),DM6446)
    LINUX_SRC = /home/fonchi/work/soc/ti-davinci
    endif
    ifeq ($(PLATFORM),MT85XX)
    LINUX_SRC = /home/john/MTK/BDP_Linux/linux-2.6.27
    CROSS_COMPILE = armv6z-mediatek-linux-gnueabi-
    endif
    ifeq ($(PLATFORM),NXP_TV550)
    LINUX_SRC = /data/tv550/kernel/linux-2.6.28.9
    LINUX_SRC_MODULE = /data/tv550/kernel/linux-2.6.28.9/drivers/net/wireless
    CROSS_COMPILE = /opt/embeddedalley/nxp_tv550/bin/mipsel-linux-
    endif
    ifeq ($(PLATFORM),MVL5)
    LINUX_SRC = /home2/charlestu/AP-VT3426/linux-2.6.18
    CROSS_COMPILE = /opt/montavista/pro/devkit/arm/v5t_le_mvl5/bin/arm_v5t_le-
    endif
    export OSABL RT28xx_DIR RT28xx_MODE LINUX_SRC CROSS_COMPILE CROSS_COMPILE_INCLUDE PLATFORM RELEASE CHIPSET RTMP_SRC_DIR LINUX_SRC_MODULE TARGET
    # The targets that may be used.
    PHONY += all build_tools test UCOS THREADX LINUX release prerelease clean uninstall install libwapi osabl
    all: build_tools $(TARGET)
    build_tools:
    $(MAKE) -C tools
    $(RT28xx_DIR)/tools/bin2h
    test:
    $(MAKE) -C tools test
    LINUX:
    ifneq (,$(findstring 2.4,$(LINUX_SRC)))
    cp -f os/linux/Makefile.4 $(RT28xx_DIR)/os/linux/Makefile
    $(MAKE) -C $(RT28xx_DIR)/os/linux/
    cp -f $(RT28xx_DIR)/os/linux/rt$(CHIPSET)sta.o /tftpboot
    else
    cp -f os/linux/Makefile.6 $(RT28xx_DIR)/os/linux/Makefile
    ifeq ($(PLATFORM),DM6446)
    $(MAKE) ARCH=arm CROSS_COMPILE=arm_v5t_le- -C $(LINUX_SRC) SUBDIRS=$(RT28xx_DIR)/os/linux modules
    else
    ifeq ($(PLATFORM),FREESCALE8377)
    $(MAKE) ARCH=powerpc CROSS_COMPILE=$(CROSS_COMPILE) -C $(LINUX_SRC) SUBDIRS=$(RT28xx_DIR)/os/linux modules
    else
    $(MAKE) -C $(LINUX_SRC) SUBDIRS=$(RT28xx_DIR)/os/linux modules
    endif
    endif
    endif
    clean:
    ifeq ($(TARGET), LINUX)
    cp -f os/linux/Makefile.clean os/linux/Makefile
    $(MAKE) -C os/linux clean
    rm -rf os/linux/Makefile
    endif
    uninstall:
    ifeq ($(TARGET), LINUX)
    ifneq (,$(findstring 2.4,$(LINUX_SRC)))
    $(MAKE) -C $(RT28xx_DIR)/os/linux -f Makefile.4 uninstall
    else
    $(MAKE) -C $(RT28xx_DIR)/os/linux -f Makefile.6 uninstall
    endif
    endif
    install:
    ifeq ($(TARGET), LINUX)
    ifneq (,$(findstring 2.4,$(LINUX_SRC)))
    $(MAKE) -C $(RT28xx_DIR)/os/linux -f Makefile.4 install
    else
    $(MAKE) -C $(RT28xx_DIR)/os/linux -f Makefile.6 install
    endif
    endif
    # Declare the contents of the .PHONY variable as phony. We keep that information in a variable
    .PHONY: $(PHONY)
    Here is the config.mk
    # Support ATE function
    HAS_ATE=n
    # Support ATE NEW TXCONT solution
    HAS_NEW_TXCONT=n
    # Support QA ATE function
    HAS_QA_SUPPORT=n
    # Support XLINK mode
    HAS_XLINK=n
    # Support Wpa_Supplicant
    HAS_WPA_SUPPLICANT=y
    # Support Native WpaSupplicant for Network Maganger
    HAS_NATIVE_WPA_SUPPLICANT_SUPPORT=y
    #Support Net interface block while Tx-Sw queue full
    HAS_BLOCK_NET_IF=n
    #Support DFS function
    HAS_DFS_SUPPORT=n
    #Support Carrier-Sense function
    HAS_CS_SUPPORT=n
    # Support for Multiple Cards
    HAS_MC_SUPPORT=n
    #Support for IEEE802.11e DLS
    HAS_QOS_DLS_SUPPORT=n
    #Support for EXT_CHANNEL
    HAS_EXT_BUILD_CHANNEL_LIST=n
    #Support for Net-SNMP
    HAS_SNMP_SUPPORT=n
    #Support features of 802.11n Draft3
    HAS_DOT11N_DRAFT3_SUPPORT=y
    #Support features of Single SKU.
    HAS_SINGLE_SKU_SUPPORT=n
    #Support features of 802.11n
    HAS_DOT11_N_SUPPORT=y
    HAS_KTHREAD_SUPPORT=n
    #Support statistics count
    HAS_STATS_COUNT=y
    #Support USB_BULK_BUF_ALIGMENT
    HAS_USB_BULK_BUF_ALIGMENT=n
    #Support for USB_SUPPORT_SELECTIVE_SUSPEND
    HAS_USB_SUPPORT_SELECTIVE_SUSPEND=n
    #Client support WDS function
    HAS_CLIENT_WDS_SUPPORT=n
    #Support for Bridge Fast Path & Bridge Fast Path function open to other module
    HAS_BGFP_SUPPORT=n
    HAS_BGFP_OPEN_SUPPORT=n
    #Support MAC80211 LINUX-only function
    HAS_CFG80211_SUPPORT=n
    #Support RFKILL hardware block/unblock LINUX-only function
    HAS_RFKILL_HW_SUPPORT=n
    HAS_RESOURCE_PRE_ALLOC=y
    HAS_LED_CONTROL_SUPPORT=y
    CC := $(CROSS_COMPILE)gcc
    LD := $(CROSS_COMPILE)ld
    WFLAGS := -DAGGREGATION_SUPPORT -DPIGGYBACK_SUPPORT -DWMM_SUPPORT -DLINUX -Wall -Wstrict-prototypes -Wno-trigraphs
    WFLAGS += -DSYSTEM_LOG_SUPPORT -DRT28xx_MODE=$(RT28xx_MODE) -DCHIPSET=$(CHIPSET)
    ifeq ($(HAS_RESOURCE_PRE_ALLOC),y)
    WFLAGS += -DRESOURCE_PRE_ALLOC
    endif
    ifeq ($(HAS_KTHREAD_SUPPORT),y)
    WFLAGS += -DKTHREAD_SUPPORT
    endif
    # config for STA mode
    ifeq ($(RT28xx_MODE),STA)
    WFLAGS += -DCONFIG_STA_SUPPORT -DDBG
    ifeq ($(HAS_XLINK),y)
    WFLAGS += -DXLINK_SUPPORT
    endif
    ifeq ($(HAS_WPA_SUPPLICANT),y)
    WFLAGS += -DWPA_SUPPLICANT_SUPPORT
    ifeq ($(HAS_NATIVE_WPA_SUPPLICANT_SUPPORT),y)
    WFLAGS += -DNATIVE_WPA_SUPPLICANT_SUPPORT -DCREDENTIAL_STORE -DPROFILE_STORE
    endif
    endif
    ifeq ($(HAS_ATE),y)
    WFLAGS += -DRALINK_ATE
    WFLAGS += -DCONFIG_RT2880_ATE_CMD_NEW
    ifeq ($(HAS_NEW_TXCONT),y)
    WFLAGS += -DNEW_TXCONT
    endif
    ifeq ($(HAS_QA_SUPPORT),y)
    WFLAGS += -DRALINK_QA
    endif
    endif
    ifeq ($(HAS_SNMP_SUPPORT),y)
    WFLAGS += -DSNMP_SUPPORT
    endif
    ifeq ($(HAS_QOS_DLS_SUPPORT),y)
    WFLAGS += -DQOS_DLS_SUPPORT
    endif
    ifeq ($(HAS_DOT11_N_SUPPORT),y)
    WFLAGS += -DDOT11_N_SUPPORT
    ifeq ($(HAS_DOT11N_DRAFT3_SUPPORT),y)
    WFLAGS += -DDOT11N_DRAFT3
    endif
    endif
    ifeq ($(HAS_CS_SUPPORT),y)
    WFLAGS += -DCARRIER_DETECTION_SUPPORT
    endif
    ifeq ($(HAS_STATS_COUNT),y)
    WFLAGS += -DSTATS_COUNT_SUPPORT
    endif
    ifeq ($(HAS_USB_SUPPORT_SELECTIVE_SUSPEND),y)
    WFLAGS += -DUSB_SUPPORT_SELECTIVE_SUSPEND -DCONFIG_PM
    endif
    ifeq ($(HAS_CFG80211_SUPPORT),y)
    WFLAGS += -DRT_CFG80211_SUPPORT
    ifeq ($(HAS_RFKILL_HW_SUPPORT),y)
    WFLAGS += -DRFKILL_HW_SUPPORT
    endif
    endif
    endif
    # endif of ifeq ($(RT28xx_MODE),STA)
    # Common compiler flag
    ifeq ($(HAS_EXT_BUILD_CHANNEL_LIST),y)
    WFLAGS += -DEXT_BUILD_CHANNEL_LIST
    endif
    ifeq ($(HAS_IDS_SUPPORT),y)
    WFLAGS += -DIDS_SUPPORT
    endif
    ifeq ($(OSABL),YES)
    WFLAGS += -DEXPORT_SYMTAB
    endif
    ifeq ($(HAS_CLIENT_WDS_SUPPORT),y)
    WFLAGS += -DCLIENT_WDS
    endif
    ifeq ($(HAS_BGFP_SUPPORT),y)
    WFLAGS += -DBG_FT_SUPPORT
    endif
    ifeq ($(HAS_BGFP_OPEN_SUPPORT),y)
    WFLAGS += -DBG_FT_OPEN_SUPPORT
    endif
    ifeq ($(HAS_LED_CONTROL_SUPPORT),y)
    WFLAGS += -DLED_CONTROL_SUPPORT
    endif
    # ChipSet specific definitions.
    ifeq ($(CHIPSET),2870)
    WFLAGS +=-DRTMP_MAC_USB -DRTMP_USB_SUPPORT -DRT2870 -DRT28xx -DRTMP_TIMER_TASK_SUPPORT -DA_BAND_SUPPORT
    CHIPSET_DAT = 2870
    ifeq ($(HAS_DFS_SUPPORT),y)
    WFLAGS += -DDFS_SOFTWARE_SUPPORT
    endif
    endif
    ifeq ($(CHIPSET),3572)
    WFLAGS +=-DRTMP_MAC_USB -DRTMP_USB_SUPPORT -DRT2870 -DRT28xx -DRT30xx -DRT35xx -DRTMP_TIMER_TASK_SUPPORT -DRTMP_RF_RW_SUPPORT -DRTMP_EFUSE_SUPPORT -DA_BAND_SUPPORT -DSPECIFIC_VCORECAL_SUPPORT
    CHIPSET_DAT = 2870
    ifeq ($(HAS_DFS_SUPPORT),y)
    WFLAGS += -DDFS_SOFTWARE_SUPPORT
    endif
    endif
    ifeq ($(PLATFORM),5VT)
    #WFLAGS += -DCONFIG_5VT_ENHANCE
    endif
    ifeq ($(HAS_BLOCK_NET_IF),y)
    WFLAGS += -DBLOCK_NET_IF
    endif
    ifeq ($(HAS_DFS_SUPPORT),y)
    WFLAGS += -DDFS_SUPPORT
    endif
    ifeq ($(HAS_MC_SUPPORT),y)
    WFLAGS += -DMULTIPLE_CARD_SUPPORT
    endif
    ifeq ($(PLATFORM),RMI)
    WFLAGS += -DRT_BIG_ENDIAN
    endif
    ifeq ($(PLATFORM),BL2348)
    WFLAGS += -DRT_BIG_ENDIAN
    endif
    ifeq ($(PLATFORM),BLUBB)
    WFLAGS += -DRT_BIG_ENDIAN
    endif
    ifeq ($(PLATFORM),BLPMP)
    WFLAGS += -DRT_BIG_ENDIAN
    endif
    ifeq ($(PLATFORM),RMI_64)
    WFLAGS += -DRT_BIG_ENDIAN
    endif
    ifeq ($(PLATFORM),IXP)
    WFLAGS += -DRT_BIG_ENDIAN
    endif
    ifeq ($(PLATFORM),IKANOS_V160)
    WFLAGS += -DRT_BIG_ENDIAN -DIKANOS_VX_1X0
    endif
    ifeq ($(PLATFORM),IKANOS_V180)
    WFLAGS += -DRT_BIG_ENDIAN -DIKANOS_VX_1X0
    endif
    ifeq ($(PLATFORM),INF_TWINPASS)
    WFLAGS += -DRT_BIG_ENDIAN -DINF_TWINPASS
    endif
    ifeq ($(PLATFORM),INF_DANUBE)
    ifneq (,$(findstring 2.4,$(LINUX_SRC)))
    # Linux 2.4
    WFLAGS += -DINF_DANUBE -DRT_BIG_ENDIAN
    else
    # Linux 2.6
    WFLAGS += -DRT_BIG_ENDIAN
    endif
    endif
    ifeq ($(PLATFORM),INF_AR9)
    WFLAGS += -DRT_BIG_ENDIAN -DINF_AR9
    # support MAPI function for AR9.
    #WFLAGS += -DAR9_MAPI_SUPPORT
    endif
    ifeq ($(PLATFORM),INF_VR9)
    WFLAGS += -DRT_BIG_ENDIAN -DINF_AR9 -DINF_VR9
    endif
    ifeq ($(PLATFORM),CAVM_OCTEON)
    WFLAGS += -DRT_BIG_ENDIAN
    endif
    ifeq ($(PLATFORM),BRCM_6358)
    WFLAGS += -DRT_BIG_ENDIAN -DBRCM_6358
    endif
    ifeq ($(PLATFORM),INF_AMAZON_SE)
    WFLAGS += -DRT_BIG_ENDIAN -DINF_AMAZON_SE
    endif
    ifeq ($(PLATFORM),RALINK_3052)
    WFLAGS += -DPLATFORM_RALINK_3052
    endif
    ifeq ($(PLATFORM),FREESCALE8377)
    #EXTRA_CFLAGS := -v -I$(RT28xx_DIR)/include -I$(LINUX_SRC)/include $(WFLAGS)-O2 -Wall -Wstrict-prototypes -Wno-trigraphs
    #export EXTRA_CFLAGS
    WFLAGS += -DRT_BIG_ENDIAN
    EXTRA_CFLAGS := $(WFLAGS) -I$(RT28xx_DIR)/include
    endif
    ifeq ($(PLATFORM),ST)
    #WFLAGS += -DST
    WFLAGS += -DST
    endif
    #kernel build options for 2.4
    # move to Makefile outside LINUX_SRC := /opt/star/kernel/linux-2.4.27-star
    ifeq ($(PLATFORM),RALINK_3052)
    CFLAGS := -D__KERNEL__ -I$(LINUX_SRC)/include/asm-mips/mach-generic -I$(LINUX_SRC)/include -I$(RT28xx_DIR)/include -Wall -Wstrict-prototypes -Wno-trigraphs -O2 -fno-strict-aliasing -fno-common -fomit-frame-pointer -G 0 -mno-abicalls -fno-pic -pipe -finline-limit=100000 -march=mips2 -mabi=32 -Wa,--trap -DLINUX -nostdinc -iwithprefix include $(WFLAGS)
    export CFLAGS
    endif
    ifeq ($(PLATFORM), RALINK_2880)
    CFLAGS := -D__KERNEL__ -I$(LINUX_SRC)/include -I$(RT28xx_DIR)/include -Wall -Wstrict-prototypes -Wno-trigraphs -O2 -fno-strict-aliasing -fno-common -fomit-frame-pointer -G 0 -mno-abicalls -fno-pic -pipe -finline-limit=100000 -march=mips2 -mabi=32 -Wa,--trap -DLINUX -nostdinc -iwithprefix include $(WFLAGS)
    export CFLAGS
    endif
    ifeq ($(PLATFORM),STAR)
    CFLAGS := -D__KERNEL__ -I$(LINUX_SRC)/include -I$(RT28xx_DIR)/include -Wall -Wstrict-prototypes -Wno-trigraphs -O2 -fno-strict-aliasing -fno-common -Uarm -fno-common -pipe -mapcs-32 -D__LINUX_ARM_ARCH__=4 -march=armv4 -mshort-load-bytes -msoft-float -Uarm -DMODULE -DMODVERSIONS -include $(LINUX_SRC)/include/linux/modversions.h $(WFLAGS)
    export CFLAGS
    endif
    ifeq ($(PLATFORM),SIGMA)
    CFLAGS := -D__KERNEL__ -I$(RT28xx_DIR)/include -I$(LINUX_SRC)/include -I$(LINUX_SRC)/include/asm/gcc -I$(LINUX_SRC)/include/asm-mips/mach-tango2 -I$(LINUX_SRC)/include/asm-mips/mach-tango2 -DEM86XX_CHIP=EM86XX_CHIPID_TANGO2 -DEM86XX_REVISION=6 -I$(LINUX_SRC)/include/asm-mips/mach-generic -I$(RT2860_DIR)/include -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -ffreestanding -O2 -fomit-frame-pointer -G 0 -mno-abicalls -fno-pic -pipe -mabi=32 -march=mips32r2 -Wa,-32 -Wa,-march=mips32r2 -Wa,-mips32r2 -Wa,--trap -DMODULE $(WFLAGS) -DSIGMA863X_PLATFORM
    export CFLAGS
    endif
    ifeq ($(PLATFORM),SIGMA_8622)
    CFLAGS := -D__KERNEL__ -I$(CROSS_COMPILE_INCLUDE)/include -I$(LINUX_SRC)/include -I$(RT28xx_DIR)/include -Wall -Wstrict-prototypes -Wno-trigraphs -O2 -fno-strict-aliasing -fno-common -fno-common -pipe -fno-builtin -D__linux__ -DNO_MM -mapcs-32 -march=armv4 -mtune=arm7tdmi -msoft-float -DMODULE -mshort-load-bytes -nostdinc -iwithprefix -DMODULE $(WFLAGS)
    export CFLAGS
    endif
    ifeq ($(PLATFORM),5VT)
    CFLAGS := -D__KERNEL__ -I$(LINUX_SRC)/include -I$(RT28xx_DIR)/include -mlittle-endian -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -O3 -fno-omit-frame-pointer -fno-optimize-sibling-calls -fno-omit-frame-pointer -mapcs -mno-sched-prolog -mabi=apcs-gnu -mno-thumb-interwork -D__LINUX_ARM_ARCH__=5 -march=armv5te -mtune=arm926ej-s --param max-inline-insns-single=40000 -Uarm -Wdeclaration-after-statement -Wno-pointer-sign -DMODULE $(WFLAGS)
    export CFLAGS
    endif
    ifeq ($(PLATFORM),IKANOS_V160)
    CFLAGS := -D__KERNEL__ -I$(LINUX_SRC)/include -I$(LINUX_SRC)/include/asm/gcc -I$(LINUX_SRC)/include/asm-mips/mach-tango2 -I$(LINUX_SRC)/include/asm-mips/mach-tango2 -I$(LINUX_SRC)/include/asm-mips/mach-generic -I$(RT28xx_DIR)/include -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -ffreestanding -O2 -fomit-frame-pointer -G 0 -mno-abicalls -fno-pic -pipe -march=lx4189 -Wa, -DMODULE $(WFLAGS)
    export CFLAGS
    endif
    ifeq ($(PLATFORM),IKANOS_V180)
    CFLAGS := -D__KERNEL__ -I$(LINUX_SRC)/include -I$(LINUX_SRC)/include/asm/gcc -I$(LINUX_SRC)/include/asm-mips/mach-tango2 -I$(LINUX_SRC)/include/asm-mips/mach-tango2 -I$(LINUX_SRC)/include/asm-mips/mach-generic -I$(RT28xx_DIR)/include -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -ffreestanding -O2 -fomit-frame-pointer -G 0 -mno-abicalls -fno-pic -pipe -mips32r2 -Wa, -DMODULE $(WFLAGS)
    export CFLAGS
    endif
    ifeq ($(PLATFORM),INF_TWINPASS)
    CFLAGS := -D__KERNEL__ -DMODULE -I$(LINUX_SRC)/include -I$(RT28xx_DIR)/include -Wall -Wstrict-prototypes -Wno-trigraphs -O2 -fomit-frame-pointer -fno-strict-aliasing -fno-common -G 0 -mno-abicalls -fno-pic -march=4kc -mips32 -Wa,--trap -pipe -mlong-calls $(WFLAGS)
    export CFLAGS
    endif
    ifeq ($(PLATFORM),INF_DANUBE)
    ifneq (,$(findstring 2.4,$(LINUX_SRC)))
    CFLAGS := -I$(RT28xx_DIR)/include $(WFLAGS) -Wundef -fno-strict-aliasing -fno-common -ffreestanding -Os -fomit-frame-pointer -G 0 -mno-abicalls -fno-pic -pipe -msoft-float -mabi=32 -march=mips32 -Wa,-32 -Wa,-march=mips32 -Wa,-mips32 -Wa,--trap -I$(LINUX_SRC)/include/asm-mips/mach-generic
    else
    CFLAGS := -I$(RT28xx_DIR)/include $(WFLAGS) -Wundef -fno-strict-aliasing -fno-common -ffreestanding -Os -fomit-frame-pointer -G 0 -mno-abicalls -fno-pic -pipe -msoft-float -mabi=32 -march=mips32r2 -Wa,-32 -Wa,-march=mips32r2 -Wa,-mips32r2 -Wa,--trap -I$(LINUX_SRC)/include/asm-mips/mach-generic
    endif
    export CFLAGS
    endif
    ifeq ($(PLATFORM),INF_AR9)
    CFLAGS := -I$(RT28xx_DIR)/include $(WFLAGS) -Wundef -fno-strict-aliasing -fno-common -fno-pic -ffreestanding -Os -fomit-frame-pointer -G 0 -mno-abicalls -fno-pic -pipe -msoft-float -mabi=32 -mlong-calls -march=mips32r2 -mtune=34kc -march=mips32r2 -Wa,-32 -Wa,-march=mips32r2 -Wa,-mips32r2 -Wa,--trap -I$(LINUX_SRC)/include/asm-mips/mach-generic
    export CFLAGS
    endif
    ifeq ($(PLATFORM),INF_VR9)
    CFLAGS := -I$(RT28xx_DIR)/include $(WFLAGS) -Wundef -fno-strict-aliasing -fno-common -fno-pic -ffreestanding -Os -fomit-frame-pointer -G 0 -mno-abicalls -fno-pic -pipe -msoft-float -mabi=32 -mlong-calls -march=mips32r2 -march=mips32r2 -Wa,-32 -Wa,-march=mips32r2 -Wa,-mips32r2 -Wa,--trap -I$(LINUX_SRC)/include/asm-mips/mach-generic
    export CFLAGS
    endif
    ifeq ($(PLATFORM),BRCM_6358)
    CFLAGS := $(WFLAGS) -I$(RT28xx_DIR)/include -nostdinc -iwithprefix include -D__KERNEL__ -Wall -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -I $(LINUX_SRC)/include/asm/gcc -G 0 -mno-abicalls -fno-pic -pipe -finline-limit=100000 -mabi=32 -march=mips32 -Wa,-32 -Wa,-march=mips32 -Wa,-mips32 -Wa,--trap -I$(LINUX_SRC)/include/asm-mips/mach-bcm963xx -I$(LINUX_SRC)/include/asm-mips/mach-generic -Os -fomit-frame-pointer -Wdeclaration-after-statement -DMODULE -mlong-calls
    export CFLAGS
    endif
    ifeq ($(PLATFORM),INF_AMAZON_SE)
    CFLAGS := -D__KERNEL__ -DMODULE=1 -I$(LINUX_SRC)/include -I$(RT28xx_DIR)/include -Wall -Wstrict-prototypes -Wno-trigraphs -O2 -fno-strict-aliasing -fno-common -DCONFIG_IFX_ALG_QOS -DCONFIG_WAN_VLAN_SUPPORT -fomit-frame-pointer -DIFX_PPPOE_FRAME -G 0 -fno-pic -mno-abicalls -mlong-calls -pipe -finline-limit=100000 -mabi=32 -march=mips32 -Wa,-32 -Wa,-march=mips32 -Wa,-mips32 -Wa,--trap -nostdinc -iwithprefix include $(WFLAGS)
    export CFLAGS
    endif
    ifeq ($(PLATFORM),ST)
    CFLAGS := -D__KERNEL__ -I$(LINUX_SRC)/include -I$(RT28xx_DIR)/include -Wall -O2 -Wundef -Wstrict-prototypes -Wno-trigraphs -Wdeclaration-after-statement -Wno-pointer-sign -fno-strict-aliasing -fno-common -fomit-frame-pointer -ffreestanding -m4-nofpu -o $(WFLAGS)
    export CFLAGS
    endif
    ifeq ($(PLATFORM),PC)
    ifneq (,$(findstring 2.4,$(LINUX_SRC)))
    # Linux 2.4
    CFLAGS := -D__KERNEL__ -I$(LINUX_SRC)/include -I$(RT28xx_DIR)/include -O2 -fomit-frame-pointer -fno-strict-aliasing -fno-common -pipe -mpreferred-stack-boundary=2 -march=i686 -DMODULE -DMODVERSIONS -include $(LINUX_SRC)/include/linux/modversions.h $(WFLAGS)
    export CFLAGS
    else
    # Linux 2.6
    EXTRA_CFLAGS := $(WFLAGS) -I$(RT28xx_DIR)/include
    endif
    endif
    #If the kernel version of RMI is newer than 2.6.27, please change "CFLAGS" to "EXTRA_FLAGS"
    ifeq ($(PLATFORM),RMI)
    EXTRA_CFLAGS := -D__KERNEL__ -DMODULE=1 -I$(LINUX_SRC)/include -I$(LINUX_SRC)/include/asm-mips/mach-generic -I$(RT28xx_DIR)/include -Wall -Wstrict-prototypes -Wno-trigraphs -O2 -fno-strict-aliasing -fno-common -DCONFIG_IFX_ALG_QOS -DCONFIG_WAN_VLAN_SUPPORT -fomit-frame-pointer -DIFX_PPPOE_FRAME -G 0 -fno-pic -mno-abicalls -mlong-calls -pipe -finline-limit=100000 -mabi=32 -G 0 -mno-abicalls -fno-pic -pipe -msoft-float -march=xlr -ffreestanding -march=xlr -Wa,--trap, -nostdinc -iwithprefix include $(WFLAGS)
    export EXTRA_CFLAGS
    endif
    ifeq ($(PLATFORM),RMI_64)
    EXTRA_CFLAGS := -D__KERNEL__ -DMODULE=1 -I$(LINUX_SRC)/include -I$(LINUX_SRC)/include/asm-mips/mach-generic -I$(RT28xx_DIR)/include -Wall -Wstrict-prototypes -Wno-trigraphs -O2 -fno-strict-aliasing -fno-common -DCONFIG_IFX_ALG_QOS -DCONFIG_WAN_VLAN_SUPPORT -fomit-frame-pointer -DIFX_PPPOE_FRAME -G 0 -fno-pic -mno-abicalls -mlong-calls -pipe -finline-limit=100000 -mabi=64 -G 0 -mno-abicalls -fno-pic -pipe -msoft-float -march=xlr -ffreestanding -march=xlr -Wa,--trap, -nostdinc -iwithprefix include $(WFLAGS)
    export EXTRA_CFLAGS
    endif
    ifeq ($(PLATFORM),IXP)
    CFLAGS := -v -D__KERNEL__ -DMODULE -I$(LINUX_SRC)/include -I$(RT28xx_DIR)/include -mbig-endian -Wall -Wstrict-prototypes -Wno-trigraphs -O2 -fno-strict-aliasing -fno-common -Uarm -fno-common -pipe -mapcs-32 -D__LINUX_ARM_ARCH__=5 -mcpu=xscale -mtune=xscale -malignment-traps -msoft-float $(WFLAGS)
    EXTRA_CFLAGS := -v $(WFLAGS) -I$(RT28xx_DIR)/include -mbig-endian
    export CFLAGS
    endif
    ifeq ($(PLATFORM),SMDK)
    EXTRA_CFLAGS := $(WFLAGS) -I$(RT28xx_DIR)/include
    endif
    ifeq ($(PLATFORM),CAVM_OCTEON)
    EXTRA_CFLAGS := $(WFLAGS) -I$(RT28xx_DIR)/include \
    -mabi=64 $(WFLAGS)
    export CFLAGS
    endif
    ifeq ($(PLATFORM),DM6446)
    CFLAGS := -nostdinc -iwithprefix include -D__KERNEL__ -I$(RT28xx_DIR)/include -I$(LINUX_SRC)/include -Wall -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Os -fno-omit-frame-pointer -fno-omit-frame-pointer -mapcs -mno-sched-prolog -mlittle-endian -mabi=apcs-gnu -D__LINUX_ARM_ARCH__=5 -march=armv5te -mtune=arm9tdmi -msoft-float -Uarm -Wdeclaration-after-statement -c -o $(WFLAGS)
    export CFLAGS
    endif
    ifeq ($(PLATFORM),BL2348)
    CFLAGS := -D__KERNEL__ -I$(RT28xx_DIR)/include -I$(LINUX_SRC)/include -I$(LINUX_SRC)/include/asm/gcc -I$(LINUX_SRC)/include/asm-mips/mach-tango2 -I$(LINUX_SRC)/include/asm-mips/mach-tango2 -DEM86XX_CHIP=EM86XX_CHIPID_TANGO2 -DEM86XX_REVISION=6 -I$(LINUX_SRC)/include/asm-mips/mach-generic -I$(RT2860_DIR)/include -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -ffreestanding -O2 -fomit-frame-pointer -G 0 -mno-abicalls -fno-pic -pipe -mabi=32 -march=mips32r2 -Wa,-32 -Wa,-march=mips32r2 -Wa,-mips32r2 -Wa,--trap -DMODULE $(WFLAGS) -DSIGMA863X_PLATFORM -DEXPORT_SYMTAB -DPLATFORM_BL2348
    export CFLAGS
    endif
    ifeq ($(PLATFORM),BLUBB)
    CFLAGS := -D__KERNEL__ -I$(RT28xx_DIR)/include -I$(LINUX_SRC)/include -I$(LINUX_SRC)/include/asm/gcc -I$(LINUX_SRC)/include/asm-mips/mach-tango2 -I$(LINUX_SRC)/include/asm-mips/mach-tango2 -DEM86XX_CHIP=EM86XX_CHIPID_TANGO2 -DEM86XX_REVISION=6 -I$(LINUX_SRC)/include/asm-mips/mach-generic -I$(RT2860_DIR)/include -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -ffreestanding -O2 -fomit-frame-pointer -G 0 -mno-abicalls -fno-pic -pipe -mabi=32 -march=mips32r2 -Wa,-32 -Wa,-march=mips32r2 -Wa,-mips32r2 -Wa,--trap -DMODULE $(WFLAGS) -DSIGMA863X_PLATFORM -DEXPORT_SYMTAB -DPLATFORM_BL2348
    export CFLAGS
    endif
    ifeq ($(PLATFORM),BLPMP)
    CFLAGS := -D__KERNEL__ -I$(RT28xx_DIR)/include -I$(LINUX_SRC)/include -I$(LINUX_SRC)/include/asm/gcc -I$(LINUX_SRC)/include/asm-mips/mach-tango2 -I$(LINUX_SRC)/include/asm-mips/mach-tango2 -DEM86XX_CHIP=EM86XX_CHIPID_TANGO2 -DEM86XX_REVISION=6 -I$(LINUX_SRC)/include/asm-mips/mach-generic -I$(RT2860_DIR)/include -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -ffreestanding -O2 -fomit-frame-pointer -G 0 -mno-abicalls -fno-pic -pipe -mabi=32 -march=mips32r2 -Wa,-32 -Wa,-march=mips32r2 -Wa,-mips32r2 -Wa,--trap -DMODULE $(WFLAGS) -DSIGMA863X_PLATFORM -DEXPORT_SYMTAB
    export CFLAGS
    endif
    ifeq ($(PLATFORM),MT85XX)
    ifneq (,$(findstring 2.4,$(LINUX_SRC)))
    # Linux 2.4
    CFLAGS := -D__KERNEL__ -I$(LINUX_SRC)/include -I$(RT28xx_DIR)/include -O2 -fomit-frame-pointer -fno-strict-aliasing -fno-common -pipe -mpreferred-stack-boundary=2 -march=i686 -DMODULE -DMODVERSIONS -include $(LINUX_SRC)/include/linux/modversions.h $(WFLAGS)
    export CFLAGS
    else
    # Linux 2.6
    EXTRA_CFLAGS += $(WFLAGS) -I$(RT28xx_DIR)/include
    EXTRA_CFLAGS += -D _NO_TYPEDEF_BOOL_ \
    -D _NO_TYPEDEF_UCHAR_ \
    -D _NO_TYPEDEF_UINT8_ \
    -D _NO_TYPEDEF_UINT16_ \
    -D _NO_TYPEDEF_UINT32_ \
    -D _NO_TYPEDEF_UINT64_ \
    -D _NO_TYPEDEF_CHAR_ \
    -D _NO_TYPEDEF_INT32_ \
    -D _NO_TYPEDEF_INT64_ \
    endif
    endif
    ifeq ($(PLATFORM),NXP_TV550)
    ifneq (,$(findstring 2.4,$(LINUX_SRC)))
    # Linux 2.4
    CFLAGS := -D__KERNEL__ -I$(LINUX_SRC)/include -I$(RT28xx_DIR)/include -O2 -fomit-frame-pointer -fno-strict-aliasing -fno-common -pipe -mpreferred-stack-boundary=2 -march=mips -DMODULE -DMODVERSIONS -include $(LINUX_SRC)/include/linux/modversions.h $(WFLAGS)
    export CFLAGS
    else
    # Linux 2.6
    EXTRA_CFLAGS := $(WFLAGS) -I$(RT28xx_DIR)/include
    endif
    endif
    ifeq ($(PLATFORM),MVL5)
    CFLAGS := -D__KERNEL__ -I$(LINUX_SRC)/include -I$(RT28xx_DIR)/include -mlittle-endian -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -O3 -fno-omit-frame-pointer -fno-optimize-sibling-calls -fno-omit-frame-pointer -mapcs -mno-sched-prolog -mno-thumb-interwork -D__LINUX_ARM_ARCH__=5 -march=armv5te -mtune=arm926ej-s --param max-inline-insns-single=40000 -Uarm -Wdeclaration-after-statement -Wno-pointer-sign -DMODULE $(WFLAGS)
    export CFLAGS
    endif

  • Variable size

    So
    boolean is 1 byte
    byte is 1 byte
    short is 2 bytes
    int is 4 bytes
    long is 8 bytes .
    How many bytes are float and double?
    How many bytes has a pointer?
    Can I look this up somewhere on this website or in the documentation? I have not found it.
    Is there any way to find out how large a certain object is?
    About boolean: AFAIK 1 is true and 0 is false. What about numbers other than 1 and 0? Will all numbers unequal 0 turn out to true, or will (binary) numbers ending in 0 be false and those ending in 1 be true? Not that it really matters, as one cannot convert booleans to numbers or v.v. in Java.
    Monika.

    There is no such thing as a pointer in Java.Yes, there are, there is just no pointerarithmetic.
    I still have to disagree with you. they r called
    as reference and not pointer. pointers r really
    different from references.I think pointers and references are the same. What is
    the difference?From the index to the language specification
    pointers
    See references
    Also from the Language Specification 4.3.1 http://java.sun.com/docs/books/jls/second_edition/html/typesValues.doc.html#9317
    An object is a class instance or an array.
    The reference values (often just references) are pointers to these objects, and a special null reference, which refers to no object.
    Seems to say that references and pointers are the same thing.
    Col

  • Max No of Columns allowed in MAXDB 7.5.00.18

    Hello,
    How many Maximum No of Columns are allowed for a Table in MaxDB.And also tell me how many bytes a float,double,small int  etc takes in MaxDb.
        I have seen in help of MaxDB that a table allows 1024 columns including primary key.But the Internal length of a table row is  8088 bytes.But a Long varchar allows 2GB.i don't understand  Long Varchar
    Size is Greater than Internal length of a table row.Can anyone explain this.
    Thanks in Advance,
    Venkat

    Hi,
    in addition to the explanation from Elke, you may want to have a look into a more general description on the topic "data storage in MaxDB".
    I recommend you check the documentation and/or the freely available MaxDB Internals Course material:
    [http://maxdb.sap.com/training/]
    The link
    [No-Reorganization Principle; Data Storage Without I/O Bottlenecks|http://maxdb.sap.com/training/internals_7.6/reorgfree_EN_76.pdf]
    points to a quite complete description of how MaxDB stores data.
    Best regards,
    Lars

  • Binary file reading

    Dear All,
    I have Binary file. I want to read Bytes based on Patterns and each channel value (Byte values -- > Float conversion)  and storing it into Index array.
    Please check the attachment for pattren format. 
    Here, the biggest problem is we will get only pattern style, Based on pattern the data is already stored in Binary file just we need to read it means we need to set the Timestamp based on this.
    Please give me some idea to read this kind of pattern files.
    BR,
    Guru
    Munna
    Attachments:
    Data Reading.xlsx ‏15 KB
    Data Reading.xlsx ‏15 KB

    Hi Munna,
    that pattern is quite hard to understand. It seems there is some information missing…
    In your pattern table the data size for e.g. ch1 is given as "1 byte", but in your time schedule you use two bytes for ch1. How are those "ch start position bytes" to be identified?
    Byte values -- > Float conversion
    How do you want to convert those bytes to Float (SGL or DBL)?
    storing it into Index array
    What is an "index array"?
    It seems you have to create a table from your pattern which identifies the bytes in the file. That seems to be the trickiest part as in your pattern#2 example you already have made a mistake (for ch4 there is no marking at timestamp 70ms)…
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • Double imprecision?

    is there imprecision with double data types? last night I was doing a topcoder.com competition (which is over now) where the 500 point problem involved double variables which you had to multiply divide. even in the question it said: "Watch out for double imprecision. The expected number of sales per month, without rounding, is exactly 36091." when I tried that porblem, mine would get all the results right but would get 36091.0001 or something like that. where can I find more information on this?

    Hi Rahde,
    I think you mean "double precision". The term is a holdover from FORTRAN where doubles had twice as many bytes as floats. You can represent larger (and smaller) numbers with doubles.
    If you write a function like a zeroth-order Bessel function of the first kind J0 with floats, the values will degrade quickly for large arguments. Doubles will represent the function faithfully longer.
    People who do scientific computing will usually write their code using doubles.
    A Google search using "double precision" will turn up a lot. This isn't bad:
    http://systems.webopedia.com/TERM/D/double_precision.html
    HTH - MOD

  • Hidden Special Characters in Variable

    I am having a weird issue and for the life of me cannot figure out the root cause.  I have a query that is pulling back some data including a summed money data type from sqlserver called totalAmount.  We are looping over these rows and adding up some totals of the rows such as:
    <cfset myAA = 0 />
    <cfset myAB = 0 />
    <cfloop ... >
    <cfif ... >
    <cfset myAA = myAA + getPayments.totalAmount />
    <cfelse>
    <cfset myAB = myAB+ getPayments.totalAmount />
    </cfif>
    </cfloop>
    At this point we add the 2 together...
    <cfset mySum = myAA + myAB />
    We are expecting this to be 0, but in one instance it is not so, even though it should be.
    Outputting the two variables gives them as -75.03 and 75.03.  When these are added together the result is:
    -1.05160324892E-012
    If I do a trim like:
    <cfset mySum = trim(myAA) + trim(myAB) />
    It returns 0.  So it seems there is an additional character on one or both of those variables, but what is it and where is it coming from?  If I output:
    (#myAA#) + (#myAB#)
    I get (-75.03) + (75.03).  So no whitespace... If I do a len() on each I get 6 and 5.
    If I do a compare such as #myAA# => #(myAA eq "-75.03")#
    I get -75.03 => NO, same with the other.
    So I am dumbfounded, it seems there is a control character there that is hidden and throwing this off.  Anyone have any suggestions on what to check or any ideas what the problem may be?  I would rather fix the problem at the root rather than throwing trim() around variables that should be numeric to begin with.
    -Shawn

    BKBK's explanation is slightly wide of the mark, in mentioning that floats are all stored with an intrinsically high number of decimal places.
    You misquote me. I didn't say intrinsic. I said arbitrary, twice even.
    I am aware of binary representation and storage of numbers in memory. However, I intentionally kept the technicalities to a minimum, without losing the essence, so that it can make sense to Smholstein.
    Whilst they can have a high number of decimal places, they don't automatically (1 will be stored with no decimal places; 1.5 will be stored with one DP, etc), and the "number of decimal places" is not really the correct way of looking at it.  For one thing, all numbers are stored in binary, not decimal, so there is no such thing as a decimal place.  A Double is 64-bit, which - if I'm reading the spec right, gives around 15 digits of decimal precision, and an exponent (of 10) range of 308 orders.  So this means one could express 123456789012345 or 0.123456789012345E-308.  But one could not represent 1234567890.123456: it's good too high a level of precision (16 digits; wherein a Double can only do 15).
    Secondly, decimal fractions are not very easy to express in binary.  The only way binary has to express a number is in varying powers of 2, eg: 42 is  101010 in binary (32+8+2 or 1*2^5 + 0*2^4 + 1*2^3 + 0*2^2 + 1*2^1 + 0*2^0).  When expressing fractions, it has to do the same thing.  2.5 is 1*2^1 + 0*2^0 + 1*2^-1. Easy.  But what about 2.3?  It's easy in decimal, but actually not possible to represent in binary (try expressing 0.3 only using sums of 2 raised to negative powers...).  So intrinsically, many many floating point numbers are not possible to completely accurately represent in binary; the computer can only make a reasonably good approximation by calculating it to a reasonable number of significant figures.  This means that under the hood, 2.3 might be represented as 2.3000000000000001 or something.  This is inate to floating point representation.
    Brave attempt! However, there are far too many technicalities and intricacies about floating points than we have time or space for in this forum. It is sufficient to say that ColdFusion's underlying machine, Java, uses the IEEE 754 standard for representing floats and doubles. 
    According to this standard, a  float is a single-precision, 32-bit floating-point number. Whereas a double is double-precision 64-bit floating-point number. A float requires up to 4 bytes of storage in memory, a double, 8 bytes. Floats have a precision of 23 binary digits, and doubles, 52.
    Those are the limitations that make it impossible for the computer to represent, for example, 2.3 with exact precision. However, that doesn't mean that it is impossible to represent 2.3 in binary! It is infact possible to so, but it requires an arbitrarily large number of terms. Here it goes:
    2.3 = 2 + 1/4 + 1/32 + 1/64 + 1/512 + 1/1024 + 1/8192 + 1/16384 + 1/131072 + 1/262144 + ...
    Now, there's a vagary in CF that when one converts a floating point number to a string it internally "fixes" this approximation, so it'll convert 2.3000000000000001 to "2.3" as a string.  So if you output a float, it'll get "fixed", and if you use a float as an argument value for a string function (like trim), it'll also get "fixed".  That's why trimming your value seems to fix the problem.  It's really just a side-effect of the way CF converts floats to strings.
    I think it's a bit more complicated than that. It can actually happen the other way round. That is, that ColdFusion may cast from the float 2.3 to the double 2.3000000000000001. That is what happened to Smholstein.
    On the other hand, there are times when ColdFusion may round off numbers. This can happen, for example, if the number of digits after the decimal point exceeds, say, 12.
    Run the following test. You will find that the 'fixing' you describe fails to work for y. The results are, respectively, 2.3 and 2.30000000001.
    <cfset x = trim(2.300000000001)>
    <cfset y = trim(2.30000000001)>
    <!--- Add 0 to make ColdFusion convert to numbers --->
    trim(2.300000000001) + 0 = <cfoutput>#x+0#</cfoutput><br>
    trim(2.30000000001) + 0 = <cfoutput>#y+0#</cfoutput>

  • Converting SQL NULL data

    Hi,
    I want to distinguish zero and null from sql.
    JDBC Developers Guide and Reference
    Java represents a SQL NULL datum by the Java value null. Java datatypes fall into
    two categories: primitive types (such as byte, int, float) and object types (class
    instances). The primitive types cannot represent null. Instead, they store the null
    as the value zero (as defined by the JDBC specification). This can lead to ambiguity
    when you try to interpret your results.
    In contrast, Java object types can represent null. The Java language defines an
    object wrapper type corresponding to every primitive type (for example, Integer
    for int, Float for float) that can represent null. The object wrapper types must
    be used as the targets for SQL data to detect SQL NULL without ambiguity.
    How can used?

    You can build two hierarchies under the same dimesion,one for the member of MARKET and another for the member of No Market,using the filter at the same time .

  • Change image contrast

    Hi,
    I need to change image contrast, that code working for .bmp image only.
    public static BufferedImage rescale(BufferedImage indexed,
                   float scaleFactor, float offset) {
              System.out.println(indexed.getHeight());
              IndexColorModel icm = (IndexColorModel) indexed.getColorModel();
              return new BufferedImage(rescale(icm, scaleFactor, offset), indexed
                        .getRaster(), false, null);
    public static IndexColorModel rescale(IndexColorModel icm,
                   float scaleFactor, float offset) {
              int size = icm.getMapSize();
              byte[] reds = new byte[size], greens = new byte[size], blues = new byte[size], alphas = new byte[size];
              icm.getReds(reds);
              icm.getGreens(greens);
              icm.getBlues(blues);
              icm.getAlphas(alphas);
              rescale(reds, scaleFactor, offset);
              rescale(greens, scaleFactor, offset);
              rescale(blues, scaleFactor, offset);
              return new IndexColorModel(8, size, reds, greens, blues, alphas);
         public static void rescale(byte[] comps, float scaleFactor, float offset) {
              for (int i = 0; i < comps.length; ++i) {
                   int comp = 0xff & comps;
                   int newComp = Math.round(comp * scaleFactor + offset);
                   if (newComp < 0)
                        newComp = 0;
                   else if (newComp > 255)
                        newComp = 255;
                   comps[i] = (byte) newComp;
         }If i am use .jpeg or .jpg image then following error will appearjava.lang.ClassCastException: java.awt.image.ComponentColorModel
         at com.maan.image.DAO.ImageBean.rescale(ImageBean.java:141)
         at com.maan.image.DAO.ImageBean.loadImage(ImageBean.java:39)
         at org.apache.jsp.imgManipulation.alterImage_jsp._jspService(org.apache.jsp.imgManipulation.alterImage_jsp:59)
         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:99)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:325)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
         at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:825)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:738)
         at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:526)
         at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
         at java.lang.Thread.run(Thread.java:595)any one help me, what i am going to do,
    Thanks in advance.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    My guess is that it's this line:
    IndexColorModel icm = (IndexColorModel) indexed.getColorModel(); The BufferedImage that you are sending to rescale probably uses a ComponentColorModel when you load from a .jpg and an IndexColorModel when you load from a .bmp file. You can't cast between the two. You may be able to do what you're trying to do by using the getRBG method from BufferedImage and forget about the ColorModel.

  • Join creation between 2 tables while duplicate records exist

    Hi all ,
    I have following 2 tables. I need to join both table on SAM_CUST_ID col in ABC (detail table) and DE_CUST_DI (UK) in XYZ (master table). But both columns contain duplicate values of customer because we load these table from anther database.Is there any solution that how can i join these tables by using DE_CUST_ID and SAM_CUST_ID.If I create Enable Novalidate constraint on these columns thery are working ??? Any suggestion would be highly appriciated.
    Regards
    REM TEST XYZ
      CREATE TABLE "TEST"."XYZ"
       (     "DE_BANK_ID" VARCHAR2(255 BYTE),
         "DE_CUST_ID" NUMBER(*,0),
         "XYZ_NO" NUMBER(*,0),
         "DE_HOLD_OUTPUT" VARCHAR2(255 BYTE),
         "DE_SHORT_NAME" VARCHAR2(255 BYTE),
         "DE_NAME1" VARCHAR2(255 BYTE),
         "DE_NAME2" VARCHAR2(255 BYTE),
         "DE_STREET_ADDR" VARCHAR2(255 BYTE),
         "DE_TOWN_COUNTRY" VARCHAR2(255 BYTE),
         "DE_POST_CODE" NUMBER(*,0),
         "DE_COUNTRY" VARCHAR2(255 BYTE),
         "DE_COPIES" NUMBER(*,0),
         "DE_EMAIL" VARCHAR2(255 BYTE),
         "DE_LOCAL_A1" VARCHAR2(255 BYTE),
         "DE_LOCAL_A2" VARCHAR2(255 BYTE),
         "DE_LOCAL_A3" VARCHAR2(255 BYTE),
         "DE_LOCAL_N1" FLOAT(126),
         "DE_LOCAL_N2" FLOAT(126),
         "DE_LOCAL_N3" FLOAT(126),
          CONSTRAINT "XYZ_UNIQUE" UNIQUE ("DE_CUST_ID", "XYZ_NO") ENABLE
    REM TEST XYZ_IDX1
      CREATE UNIQUE INDEX "WH1"."XYZ_IDX1" ON "WH1"."XYZ" ("DE_CUST_ID", "XYZ_NO")
    REM TEST ABC
      CREATE TABLE "TEST"."ABC"
       (     "ABC_BANK_ID" VARCHAR2(255 BYTE),
         "ABC_CUST_ID" NUMBER(22,0),
         "ABC_ABC_ID" VARCHAR2(255 BYTE),
         "ABC_PORT_NAME" VARCHAR2(255 BYTE),
         "ABC_CCY" VARCHAR2(255 BYTE),
         "ABC_INDICATOR" NUMBER(*,0),
         "ABC_MANAGED_ACCOUNT" VARCHAR2(255 BYTE),
         "ABC_CLOSED_DATE" DATE,
         "ABC_INVESTMENT_PGM" VARCHAR2(255 BYTE),
         "ABC_ACC_OFF" NUMBER(*,0),
         "ABC_FREQUENCY" VARCHAR2(255 BYTE),
          CONSTRAINT "ABC_UNIQUE" UNIQUE ("ABC_ABC_ID") ENABLE,
          CONSTRAINT "ABC_DE_ADD_CUSID_FK" FOREIGN KEY ("ABC_CUST_ID")
           REFERENCES "WH1"."DE_ADDR" ("DE_CUST_ID") ENABLE NOVALIDATE
    REM WH1 ABC_UNIQUE
      CREATE UNIQUE INDEX "WH1"."ABC_UNIQUE" ON "WH1"."ABC" ("ABC_ABC_ID")
     

    would u like to explain by an example?First of all why not removing duplicates
    If you need to keep duplicates, you entire design looks wrong.
    You have to follow normalization rules and always have LPK (logical primary key) and PK for transactional tables
    An example is simple
    A1 and B2 duplicates
    After data is loaded it should look like this
    Table 1
    id val
    1 A1
    2 A1
    3 B2
    4 B2
    Table 2
    id val
    1 A1
    2 A1
    3 B2
    4 B2--
    (id - unique sequence)
    Of cause there is more possibility but
    nobody can tell you how to do this (or what to do) based on what you showed.
    Good luck

Maybe you are looking for