Problem reading data from database

Hi All,
I'm doing some test with Oracle Coherence, particulary testing partitioned cache of a database. I'm using a client/server archictecture and I developed my own CacheStore. So, the problem is, after start the server and the client, when i do a get() in the client for a object that is on database and not in the cache, the cache answer is it doesn't exist. Isn't it supposed the cache "call" the cache store and read/verify if it is on database?
My Configuration file:
<?xml version="1.0"?>
<!DOCTYPE cache-config SYSTEM "cache-config.dtd">
<cache-config>
<caching-scheme-mapping>
<cache-mapping>
<cache-name>Recharge</cache-name>
<scheme-name>partitioned-cache</scheme-name>
</cache-mapping>
</caching-scheme-mapping>
<caching-schemes>
<distributed-scheme>
<scheme-name>partitioned-cache</scheme-name>
<backing-map-scheme>
<read-write-backing-map-scheme>
<write-delay>0</write-delay>
<read-only>false</read-only>
<internal-cache-scheme>
<local-scheme>
<scheme-name>InMemoryScheme</scheme-name>
</local-scheme>
</internal-cache-scheme>
<cachestore-scheme>
<class-scheme>
<class-name>RechargeCacheStore</class-name>
</class-scheme>
</cachestore-scheme>
</read-write-backing-map-scheme>
</backing-map-scheme>
<listener/>
<autostart>true</autostart>
</distributed-scheme>
</caching-schemes>
</cache-config>
Tanks,
Paulo Sousa

Hi Paolo,
You should use a fully qualified class name to enable the JVM class loader to find the RechargeCacheStore class.
Regards,
Harv

Similar Messages

  • Problem reading data from oracle database 11g using OleDbDataReader

    Hi everyone I work with Visual Studio 2010 and C# programming language. I have a problem reading data from the oracle database. I created a WPF application with my main Window Xaml and class files and 1 more class called DataFiles. The thing I want is to read some data from the database on my grid in my WPF window. Problem is even though it connects to the database the grid is always empty. It isn't the connection string as I tested it and it connects to the database the problem seems to be in showing the LASTNAME (PREZIME in my native tongue) on the grid which is what it's supposed to do.
    Here is the code:
    Data Files Code
    using System;
    using System.Collections.ObjectModel;
    using System.Data.SqlClient;
    using System.Data.OleDb;
    namespace SQLKonekcija
        public class clsEmployee
            public string Prezime { get; set; }
        public class DataAccess
            OleDbConnection oleCon;
            OleDbCommand oleComd;
            public DataAccess()
                string connectionString = "provider=ORAOLEDB.ORACLE; data source=ORCL; password=****; user id=****;";
                oleCon = new OleDbConnection(connectionString);
            public ObservableCollection<clsEmployee> GetAllEmployee()
                ObservableCollection<clsEmployee> EmpCol = new ObservableCollection<clsEmployee>();
                oleComd = new OleDbCommand();
                oleComd.Connection = oleCon;
                oleComd.CommandText = "Select PREZIME from UPOSLENICI";
                oleCon.Open();
                OleDbDataReader Reader = oleComd.ExecuteReader();
                Reader.Read();
                while (Reader.Read())
                    EmpCol.Add(new clsEmployee()
                        Prezime = Reader["PREZIME"].ToString()
                oleCon.Close();
                return EmpCol;
            }And here is my main window.cs code
    public partial class MainWindow : Window
            clsEmployee objEmpToAdd;
            DataAccess objDs;
            public MainWindow()
                InitializeComponent();
            private void Window_Loaded(object sender, RoutedEventArgs e)
                objDs = new DataAccess();
                dgEmp.ItemsSource = objDs.GetAllEmployee();And the XAML
    <Window x:Class="SQLKonekcija.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            Title="MainWindow" Height="350" Width="525" Loaded="Window_Loaded">
        <Grid>
            <DataGrid AutoGenerateColumns="False" Height="237"
                      HorizontalAlignment="Left" Margin="18,66,0,0" Name="dgEmp"
                      VerticalAlignment="Top" Width="466" ColumnWidth="*"
                       >
                <DataGrid.Columns>
                    <DataGridTextColumn Binding="{Binding PREZIME}" Header="Prezime"></DataGridTextColumn>
                </DataGrid.Columns>
            </DataGrid>
            <TextBlock Height="42" HorizontalAlignment="Left" Margin="18,15,0,0" Name="textBlock1" Text="TEST CONNECTION" VerticalAlignment="Top" Width="462" TextAlignment="Center" FontSize="28" FontWeight="ExtraBold" />
        </Grid>
    </Window>
    The guys on the MSDN forums told me I should ask the question here so sorry if it's not your field.
    Hope u guys can help, thanks.

    I tried it, commented out the reader.read and have the following connection string
    string connectionString = "provider=ORAOLEDB.ORACLE; data source=ORCL; password=****; user id=****; OLEDB.NET=True"
    Unfortunately the result is the same.
    Edited by: Dino2dy on Nov 24, 2011 12:53 AM

  • Urgent help with simple BPEL process for reading data from database

    Hello there,
    I need help with BPEL project.
    i have created a table Employee in Database.
    I did create application, BPEL project and connection to the database properly using Database Adapter.
    I need to read the records from the database and convert into xml fomat and it should to go approval for BPM worklist.
    Can someone please describe me step by step what i need to do.
    Thx,
    Dps

    I have created a table in Database with data like Empno,name,salary,comments.
    I created Database Connection in jsp page and connecting to BPEL process.
    It initiates the process and it goes automatically for approval.
    Please refer the code once which i created.
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <%@page import="java.util.Map" %>
    <%@page import="com.oracle.bpel.client.Locator" %>
    <%@page import="com.oracle.bpel.client.NormalizedMessage" %>
    <%@page import="com.oracle.bpel.client.delivery.IDeliveryService" %>
    <%@page import="javax.naming.Context" %>
    <%@page import="java.util.Hashtable" %>
    <%@page import="java.util.HashMap" %>
    <%@ page import="java.sql.*"%>
    <%@ page import= "jspprj.DBCon"%>
    <html>
    <head>
    <title>Invoke CreditRatingService</title>
    </head>
    <body>
    <%
    DBCon dbcon=new DBCon();
    Connection conn=dbcon.createConnection();
    Statement st=null;
    PreparedStatement pstmt=null;
    Hashtable env= new Hashtable();
    ResultSet rs = null;
    Map payload =null;
    try
    env.put(Context.INITIAL_CONTEXT_FACTORY, "com.evermind.server.rmi.RMIInitialContextFactory");
    env.put(Context.PROVIDER_URL, "opmn:ormi://localhost:port:home/orabpel");//bpel server
    env.put("java.naming.security.principal", "username");
    env.put("java.naming.security.credentials", "password");//bpel console
    Locator locator = new Locator("default","password",env);
    IDeliveryService deliveryService =
    (IDeliveryService)locator.lookupService(IDeliveryService.SERVICE_NAME );
    // construct the normalized message and send to Oracle BPEL Process Manager
    NormalizedMessage nm = new NormalizedMessage();
    java.util.HashMap map = new HashMap();
    st=conn.createStatement();
    out.println("connected");
    String query1="Select * from EMPLOYEE";
    rs=st.executeQuery(query1);
    /*reading Data From Database and converting into XML format
    so that no need of going to BPEL console and entering the details.
    while (rs.next()){
    String xml1 = "<AsynchBPELProcess1ProcessRequest xmlns='http://xmlns.oracle.com/AsynchBPELProcess1'>"+
    "<Empno>"+rs.getString(1)+"</Empno>"+
    "<EmpName>"+rs.getString(2)+"</EmpName>"+
    "<Salary>"+rs.getString(3)+"</Salary>"+
    "<Comments>"+rs.getString(4)+"</Comments>"+
    "</AsynchBPELProcess1ProcessRequest>";
    out.println(xml1);
    nm.addPart("payload", xml1 );
    // EmployeeApprovalProcess is the BPEL process in which human task is implemented
    deliveryService.post("EmployeeApprovalProcess", "initiate", nm);
    // payload = res.getPayload();
    out.println( "BPELProcess CreditRatingService executed!<br>" );
    // out.println( "Credit Rating is " + payload.get("payload") );
    //Incase there is an exception while invoking the first server invoke the second server i.e lsgpas13.
    catch(Exception ee) {
    //("BPEL Server lsgpas14 invoking error.\n"+ee.toString());
    %>
    </body>
    </html>
    Its working fine.And i want it for Bulk approvals.please help me step by step procedure if any other way to implement this.

  • JavaConsole Error: Problem reading data from server

    HI All
    We are getting this error on java console on a page:
      Error: Problem reading data from Server - Java.Security.AccessControlException:access denied (java.util.PropertyPermission http.strictpostredirect Read)
    In this page we are not firing  a SQL Query of huge data.
    Any suggestions on this why it is happening?
    Thanks
    Manisha

    Manisha,
    I think JVM(Java Virtual Machine) is trying to access something at network level and it cant able to find it.Or any new patches of java is installed.
    Or may be due to IIS or Applet,Don't know exactly.
    You can find some answers in below links:
    http://java.sun.com/j2se/1.4.2/docs/api/java/security/AccessControlException.html
    http://www.webdeveloper.com/forum/archive/index.php/t-46358.html
    -Suresh

  • Problem reading data from two tables

    Hi experts,
    I'm developing a JDBC - IDOC scenario that needs to read data from two oracle tables. I have created a BPM that has a initial fork for the two channels and it works fine.
    The problem is that I need to read data from the first, two or both tables depending if there is data to read. If there is data in the two tables it works, but if only there is data in one of the two tables, I have read problems. I have tryed to set the 'neccesary branches' to 1 but this is a problem when I have data in both tables.
    Any idea?
    Best Regards,
    Alfredo Lagunar.

    Hi,
    have your fork step inside a block and then right-click your block to insert a deadline branch to your BPM process and specify the time after which your BPM process should be cancelled.....so if in that time, you get data from both tables, your BPM will work okay otherwise if that time is over, then your BPM process will be cancelled.
    Regards,
    Rajeev Gupta

  • How to read data from database to applet

    hi i am writing a program below which reads data from mysql database successfully ;
    import java.sql.*;
    import java.lang.*;
    import java.util.*;
    public class Read_Capital_country_from_database {
    public static void main (String args[] ){
    int index,mess;
    String country_arr[] = new String[250];
    String capital_arr[] = new String[250];
    int i = 0 ;
    String URL = "jdbc:mysql://localhost/allusers";
    String user = "shadab";
    String password ="shadab@123";
    try {
    Class.forName("com.mysql.jdbc.Driver");
    Connection conn = DriverManager.getConnection(URL,user,password);
    for( SQLWarning warn = conn.getWarnings(); warn != null; warn = warn. getNextWarning() )
    System.out.println( "SQL Warning:" ) ;
    System.out.println( "State : " + warn.getSQLState() ) ;
    System.out.println( "Message: " + warn.getMessage() ) ;
    System.out.println( "Error : " + warn.getErrorCode() ) ;
    String sql = "select * from country_capital";
    Statement stmt = conn.createStatement();
    ResultSet rs = stmt.executeQuery(sql);
    while( rs.next() ) {
    System.out.println( rs.getString(1) );
    System.out.println(" " +rs.getString(2) );
    System.out.println();
    catch (SQLException se){
    System.out.println( "SQL Exception:" ) ;
    System.out.println("Exception - raju");
    while( se != null )
    System.out.println( "State : " + se.getSQLState() ) ;
    System.out.println( "Message: " + se.getMessage() ) ;
    System.out.println( "Error : " + se.getErrorCode() ) ;
    se = se.getNextException() ;
    catch( Exception e )
    System.out.println( e ) ;
    java Read_Capital_country_from_database
    OUT PUT OF ABOVE PROGRAM IS :
    INDIA NEW DELHI
    PAKISTAN ISLAMABAD
    AFGHANISTAN KABUL
    BUT SAME PROGRAM WHEN I GO TO WRITE IN APPLET
    THIS TIME APPLET DOES OPEN BUT ERROR SHOWS ON STANDARD OUT PUT
    java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
    THIS IS THE PROGRAM WRITTEN FOR JAVA APPLET
    import java.sql.*;
    import java.lang.*;
    import java.util.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.applet.*;
    public class Read_Capital_country_from_database extends Applet {
    Choice country, capital;
    String msg=" ", msg1;
    int index,mess;
    String country_arr[] = new String[250];
    String capital_arr[] = new String[250];
    char chr;
    int i = 0;
    public void init() {
    country = new Choice();
    capital = new Choice();
    String URL = "jdbc:mysql://localhost/allusers";
    String user = "shadab";
    String password ="shadab@123";
    try {
    Class.forName("com.mysql.jdbc.Driver");
    Connection conn = DriverManager.getConnection(URL,user,password);
    for( SQLWarning warn = conn.getWarnings(); warn != null; warn = warn. getNextWarning() )
    System.out.println( "SQL Warning:" ) ;
    System.out.println( "State : " + warn.getSQLState() ) ;
    System.out.println( "Message: " + warn.getMessage() ) ;
    System.out.println( "Error : " + warn.getErrorCode() ) ;
    String sql = "select * from country_capital";
    Statement stmt = conn.createStatement();
    ResultSet rs = stmt.executeQuery(sql);
    while( rs.next() ) {
    country_arr[i] = rs.getString(1);
    country.add(country_arr);
    capital_arr[i] = rs.getString(2);
    capital.add(capital_arr[i]);
    i++;
    catch (SQLException se){
    System.out.println( "SQL Exception:" ) ;
    System.out.println("Exception - raju");
    while( se != null )
    System.out.println( "State : " + se.getSQLState() ) ;
    System.out.println( "Message: " + se.getMessage() ) ;
    System.out.println( "Error : " + se.getErrorCode() ) ;
    se = se.getNextException() ;
    catch( Exception e )
    System.out.println( e ) ;
    add(country);
    add(capital);

    It doesn't make sense to read a database directly from an applet. If an applet needs data from a database is should request if from the server which the applet is located on and the server should do the actual database actions.
    The whole point of applets is that they require no installation on the client machine. If you have to change policy files or the like, you might as well install a Swing application. Furthermore accessing a database tends to depend on how the client is set up on the network. Any sensible network has firewall settings that block access to the database ports to any external access (and, again, if you are limiting the facility to a few internal machines then why not just install a program on them).

  • Problem reading data from nested internal table.

    Hi,
    Below is my code;
    *********SAP Code********
    TYPES: BEGIN OF v54a0_scdd,
             fknum  LIKE vfkk-fknum,
             change LIKE vfkkd-updkz,
             x      TYPE v54a0_scd,
             y      TYPE v54a0_scd,
             tvtf   LIKE tvtf,
           END OF v54a0_scdd.
    SCD table for dialog
    TYPES: v54a0_scdd_tab TYPE v54a0_scdd OCCURS 1.
    *********SAP Code********
    *Custom declaration*****
    data: wa_freight_costs type v54a0_scdd_tab.
    data: it_freight_costs type v54a0_scdd_tab occurs 0.
    *****Here data is getting appended to it_freight_costs. P_frieght_costs is coming from standard program.
         move p_freight_costs TO wa_FREIGHT_COSTS.
         append wa_freight_costs to it_freight_costs.
         clear wa_freight_costs.
    ***Now the problem is here. I am not able to read the data from the nested internal table x-item.
    if i use <fs_f_costs> to move data from it_freight_costs in the outer loop, i get a syntax error; <i> "the line type of the table it_freight_costs is not compatible with field symbol type <fs_f_costs>" </i>
         FIELD-SYMBOLS: <fs_f_costs> type line of v54a0_scdd_tab.
          LOOP AT it_freight_costs assigning <fs_f_costs>.
              LOOP AT <fs_f_costs>-x-item ASSIGNING <fs_freight_item>.        
                  <b> I want to read <fs_freight_item>-vfkp-netwr.</b> 
             ENDLOOP.
    Can anyone guide me?

    A quick look at how I would do this. Note I haven't checked if this compiles just done a quick brain-dump.
      DATA: lr_f_costs TYPE REF TO v54a0_scdd_tab,
            lr_f_cost TYPE REF TO v54a0_scdd.
      LOOP AT it_freight_costs REFERENCE INTO lr_f_costs.
        LOOP AT lr_f_costs->* REFERENCE INTO lr_f_cost.
        ENDLOOP.
      ENDLOOP.
    As you can see I personally prefer pointers to field symbols - I don't believe there is any performance differences and because of my background in other languages pointers make more sense to me.
    Cheers
    Graham Robbo

  • Problem Reading Data from .dat File

    I am trying to read in data from lines 384-475. The data looks something like this
    198 95 70 71 93-99-99-99-99-99-99-99-99-99-99  5 17 17 17 17-99-99-99-99-99-99-99-99-99-99 1
    78 95 70 69-99-99-99-99-99-99-99-99-99-99-99  6  2  1  1-99-99-99-99-99-99-99-99-99-99-99 2
    70 73-99-99-99-99-99-99-99-99-99-99-99-99-99  0  1-99-99-99-99-99-99-99-99-99-99-99-99-99 1This is only the data from lines 384-475. I keep getting an error though, and I can't figure it out.
    import java.util.*;
    import java.io.*;
    public class ProgrammingExercise1
         public static double findAccuracy(String systemCommand) throws IOException
             Process proc = Runtime.getRuntime().exec(systemCommand);
             Scanner scan = new Scanner(proc.getInputStream());
             PrintStream logOut = new PrintStream(new FileOutputStream("log.dat"));
             while(scan.hasNextLine())
                  logOut.println(scan.nextLine());
             logOut.close();
             scan.close();
             proc.destroy();
             Scanner input = new Scanner(new File("log.dat"));
             String line = "";
             for(int c=1; c<=4; c++)
                  line = input.nextLine();
             double finalAccuracy = Double.parseDouble(line.substring(22,27));
             input.close();
             return finalAccuracy;
         public static void main (String[] args) throws IOException
              try {
                        String s;
                        int count=0;
                        String temp;
                        int aInt;
                        int med;
                        int[] daM = new int[251];
                        String[] pos = new String[251];
                        int[][] da = new int[251][507];
                        int[] daSort = new int[da.length];
                        for (int i=0; i<251; i++)
                             daM[i] = 0;
                             for (int j=0; j<507; j++)
                                  da[i][j] = 0;
              //creating an input stream
                 FileInputStream fstream = new FileInputStream("dataset.dat");
                 DataInputStream in = new DataInputStream(fstream);
                 BufferedReader br = new BufferedReader(new InputStreamReader(in));
                 while((s = br.readLine()) != null)
                    //safety check as the last line in not null, but empty
                    //break the procedure info from the string/line
                      String sub = s.substring(384, 475);
                      for (int k=0; k<15; k++)
                           temp = sub.substring(k*3, (k*3)+3);
                             //removes spaces from the string to alleviate integer conversion errors
                           temp = temp.replace(" ", "");
                           aInt = Integer.parseInt(temp);
                           if (aInt > -1)
                                da[count][aInt] = 1;
                      sub = s.substring(260, 264);
                      temp = sub.replace(" ", "");
                      aInt = Integer.parseInt(temp);
                      if (aInt > -1)
                           daSort[count] = aInt;
                           daM[count] = aInt;
                      count++;
                 in.close();
                 bubbleSort(daSort);
                 med = daSort[daSort.length/2];
                 for (int t=0; t<daM.length; t++)
                      if (daM[t]<med)
                           pos[t] = "+1";
                      else
                           pos[t] = "-1";
                      for (int r=0; r<da[t].length; r++)
                           if (da[t][r]==1)
                                pos[t] +=" " + r + ":1.0";
                 Collections.shuffle(Arrays.asList(pos));
                 File file = new File("testSet.dat");
                 PrintWriter output = new PrintWriter(new FileWriter(file));
                 String tempOut = "";
                 for (int ii=0; ii<pos.length/4; ii++)
                      tempOut += pos[ii];
                      output.write(tempOut);
                      tempOut = "";
                      output.write("\n");
                 output.close();
                 file = new File("crossValidationSet.dat");
                 output = new PrintWriter(new FileWriter(file));
                 for (int jj=(pos.length/4); jj<pos.length/2; jj++)
                      tempOut += pos[jj];
                      output.write(tempOut);
                      tempOut = "";
                      output.write("\n");
                 output.close();
                 file = new File("trainingSet.dat");
                 output = new PrintWriter(new FileWriter(file));
                 for (int kk=(pos.length/2); kk<pos.length; kk++)
                      tempOut += pos[kk];
                      output.write(tempOut);
                      tempOut = "";
                      output.write("\n");
                 output.close();
                 System.out.println("Your file has been written");
              catch (Exception e)
                   System.err.println("Error: " + e.getMessage());
    } // end ProgrammingExercise1The main error I can't figure out is as follows... "Error: For input string: "93-"
    *Note: I had to remove some of the code due to exceeding the maximum characters allowed. I THINK the error is found at the //creating an input stream section.

    The input data that I included is the exact data I am trying to read...just three lines instead of the 251. There is plenty of other data surrounding the included data, but I am not concerned with it.
    Here is the first 3 lines of data...
    4200410577816 76-99 9 177        1 1 0  5.573125262 5 429429422MED0262      25080403915990 427322851 5789 250402859 2111                                 50  99 159 106  60 153  50  59  47-999-999-999-999-999-999                    -999-999-999-999 0 1 4025AZ   14    141010 5868 2817 9  0 04223 3 105        -9           2451644434443                                                 70 93 93-99-99-99-99-99-99-99-99-99-99-99-99  3-99-99-99-99-99-99-99-99-99-99-99-99-99-99 3     40667       40667.002004 1
    4200410581753 79-9911 177        1 1 0  5.5731252 3 5 429429422MED0262      250822851 4271 486  5789 785595990 41400V4581                                50  60 106 122 153 249 159 101 101-999-999-999-999-999-999                    -999-999-999-999 0 1 4025AZ    8     81010 2043  883 9  0 04223 2 105        -9           245134824                                                     70 77-99-99-99-99-99-99-99-99-99-99-99-99-99  4-99-99-99-99-99-99-99-99-99-99-99-99-99-99 3     25444       25444.002004 1
    4200410277559 67-99 3 177        1 0 0  5.5731252 3 5 229229221MED0236      25080707146827 4280 7318 73027041042506045981                                50 199 197 108 212 201   3  50 121-999-999-999-999-999-999                    -999-999-999-999 0 0 4047AZ   29    291010 2414 5409 9  0 04223 6 111        -9           1392745164542884288483950                                     57 70 95189190 61-99-99-99-99-99-99-99-99-99 18-99-99-99-99-99-99-99-99-99-99-99-99-99-99 1    141927      141927.002004 4
    import java.util.*;
    import java.io.*;
    public class ProgrammingExercise1 {
    public static void bubbleSort(int[] x)
              int n = x.length;
              for (int pass=1; pass < n; pass++)
                   for (int i=0; i < n-pass; i++)
                        if (x[i] > x[i+1])
                             int temp = x;
    x[i] = x[i+1];
    x[i+1] = temp;
    }// end bubbleSort
    public static void main (String[] args) throws IOException
    try {
              String s;
              int count=0;
              String temp;
              int aInt;
              int med;
              int[] daM = new int[251];
              String[] pos = new String[251];
              int[][] da = new int[251][507];
              int[] daSort = new int[da.length];
              for (int i=0; i<251; i++)
                   daM[i] = 0;
                   for (int j=0; j<507; j++)
                        da[i][j] = 0;
    FileInputStream fstream = new FileInputStream("dataset.dat");
    DataInputStream in = new DataInputStream(fstream);
    BufferedReader br = new BufferedReader(new InputStreamReader(in));
    while((s = br.readLine()) != null)
         String sub = s.substring(384, 475); //!!! Is this supposed to be (384, 475) or (384, 428)???
         for (int k=0; k<15; k++)
              temp = sub.substring(k*3, (k*3)+3);
              temp = temp.replace(" ", "");
              aInt = Integer.parseInt(temp);
              if (aInt > -1)
                   da[count][aInt] = 1;
         sub = s.substring(260, 264);
         temp = sub.replace(" ", "");
         aInt = Integer.parseInt(temp);
         if (aInt > -1)
              daSort[count] = aInt;
              daM[count] = aInt;
         count++;
    in.close();
    bubbleSort(daSort);
    med = daSort[daSort.length/2];
    for (int t=0; t<daM.length; t++)
         if (daM[t]<med)
              pos[t] = "+1";
         else
              pos[t] = "-1";
         for (int r=0; r<da[t].length; r++)
              if (da[t][r]==1)
                   pos[t] +=" " + r + ":1.0";
    Collections.shuffle(Arrays.asList(pos));
    File file = new File("testSet.dat");
    PrintWriter output = new PrintWriter(new FileWriter(file));
    String tempOut = "";
    for (int ii=0; ii<pos.length/4; ii++)
         tempOut += pos[ii];
         output.write(tempOut);
         tempOut = "";
         output.write("\n");
    output.close();
    file = new File("crossValidationSet.dat");
    output = new PrintWriter(new FileWriter(file));
    for (int jj=(pos.length/4); jj<pos.length/2; jj++)
         tempOut += pos[jj];
         output.write(tempOut);
         tempOut = "";
         output.write("\n");
    output.close();
    file = new File("trainingSet.dat");
    output = new PrintWriter(new FileWriter(file));
    for (int kk=(pos.length/2); kk<pos.length; kk++)
         tempOut += pos[kk];
         output.write(tempOut);
         tempOut = "";
         output.write("\n");
    output.close();
    System.out.println("Your file has been written");
    catch (Exception e)
         e.printStackTrace();
    Edited by: djcochran on Jan 27, 2010 5:22 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Having problem querying data from database

    I'm trying to setup a query form to see if the username and password entered is already in a database. If it is then a Static Text will give a positive message, if not then the user would be asked to register. My query doesn't seem to work, since every time I run it the Static Text doesn't show anything after I hit my submit button. Any help would be great.
    public String loginButton_action() {
    // TODO: Process the action. Return value is a navigation
    // case name where null will return to the same page.
    String currentuser = (String) regusernameTF.getValue();
    String currentpass = (String) regpasswordTF.getValue();
    try {
    connection = DriverManager.getConnection(Database_URL);
    statement = connection.createStatement();
    ResultSet resultset = statement.executeQuery(
    "SELECT Username ,Password FROM CustomerInfo" +
    "WHERE (Username =' " currentuser " ') ");
    connection.commit();
    statement.close();
    connection.close();
    String loggeduser = resultset.getString(1);
    String loggedpass = resultset.getString(2);
    boolean compare1 = loggeduser.equals(currentuser);
    boolean compare2 = loggedpass.equals(currentpass);
    if ((compare1==true) || (compare2==true)){
    messageST.setRendered(true);
    messageST.setText("Login Successful");
    else {
    messageST.setRendered(true);
    messageST.setText("Username & Password not Valid." +
    "Please Check Entry or Register to Login");
    catch (Exception e){
    e.printStackTrace();
    return null;
    Edited by: mavrik5150 on Feb 9, 2008 4:49 PM
    Edit: Forgot to mention the Database does have data already populated into it

    Hey Thanks guys for the tips, I was able to fix one problem, now I can get the Static Text field to display a message but I can't get the error message to appear when I purposly enter a wrong password or username. If I enter a correct username I get a successful message, even when I enter the wrong password. Here's the fixed code:
        public String loginButton_action() {
            // TODO: Process the action. Return value is a navigation
            // case name where null will return to the same page.
            Object currentuser =  regusernameTF.getValue();
            Object currentpass =  regpasswordTF.getValue();
            try {
            connection = DriverManager.getConnection(Database_URL);
            statement = connection.createStatement();       
            ResultSet resultset = statement.executeQuery(
                    "SELECT Username ,Password FROM CustomerInfo WHERE (Username ='"+currentuser+"') ");       
    //        connection.commit();
    //        statement.close();
    //        connection.close();   
            while (resultset.next()){
            String loggeduser = resultset.getString("username");
            String loggedpass = resultset.getString("password");
            boolean compare1 = loggeduser.equals(currentuser);
            boolean compare2 = loggedpass.equals(currentpass);
            if (compare1 || compare2){
                messageST.setRendered(true);
                messageST.setText("Login Successful");
            else {
                messageST.setRendered(true);
                messageST.setText("Username & Password not Valid." +
                        "Please Check Entry or Register to Login");
            catch (Exception e){
                e.printStackTrace();
            return null;
        }

  • Need help in reading data from Database.

    Hi experts,
    I have created a custom smartforms and custom print program. In my print program i have read all the data and populated the internal table and i am able to display the data in the smartform output.
    I'm using Tcode me23n to print preview the form. i have to read the "text" tab from the me23n tcode using FM  "READ_TEXT". The data is getting populated into an internal table. I coded these statements in Initialization tab in global definition.
    Now my problem is ..... Can anyone tell me how to display the data into the forms.
    please help.
    Thanks

    Follow below example to using FM 'READ_TEXT'
    DATA  BEGIN OF i_tlines OCCURS 0.
            INCLUDE STRUCTURE tline.
    DATA  END   OF i_tlines.
    DATA: w_textname(70) TYPE c.
      w_textname = vbdkr-vbeln.
      CALL FUNCTION 'READ_TEXT'
        EXPORTING
          client                        = sy-mandt
          id                            = 'Z006'
          language                      = 'E'
          name                          = w_textname
          object                        = 'VBBK'
        TABLES
          lines                         = i_tlines.
      IF sy-subrc = 0.
        READ TABLE i_tlines INDEX 1.
        t_in-m1 = i_tlines-tdline.   "Now t_in_m1 will have the value
      ENDIF.
    Regards,
    SaiRam

  • Problem reading data from textField?

    I have a problem in my program I'm currently doing.
    I have a textArea and a textField in a container.
    Inside the textArea will be displayed some questions which require user to give answers to in the textField.
    When user types something in the textField and presses enter, an actionListener will trigger and take in String.
    My problem is how do you wait for the user to type something in the textField?
    thanks

    Hi
    I am trying to read a value from a textField object in the following code, but its returning an empty string. any kind of help would be appreciated. thanks.
    bhavesh
    import java.awt.*;
    import java.awt.event.*;
    import java.applet.*;
    import java.io.*;
    import java.lang.*;
    public class Applet1 extends Applet implements ActionListener, TextListener{
         String text = "";
         Image logo;
         static TextField usr;
         static TextField pswd;
         static Button logOn;
         public boolean authenticate(Graphics g){
              g.setColor(Color.RED);
              g.setFont(new Font("Monospaced", Font.PLAIN, 20));
              text = "Username:";
              g.drawString(text, 300, 300);
              text = "Password:";
              g.drawString(text, 300, 325);
              g.setFont(new Font("Serif", Font.PLAIN, 20));
              usr = new TextField(40);
              usr.setBounds(420,280, 200,20);
              usr.setEditable(true);
              //usr.addActionListener(this);
              add(usr);
              //add (new Label("Enter number:"));
              pswd = new TextField(40);
              pswd.setEditable(true);
              pswd.setBounds(420,310, 200,20);
              //pswd.addActionListener(this);
              add(pswd);
              //add (new Label("Enter number:"));
         logOn = new Button("Log on ...");
         logOn.setBounds(380,340,80,20);
              logOn.addActionListener(this);
              add(logOn);
              return true;
         public void actionPerformed(ActionEvent ae){
              System.out.print(usr.getText()+"rr\n"+ae);
              System.out.print(pswd.getText()+"bb\n");
              if ( usr.getText().compareTo("gusr")==0 && pswd.getText().compareTo("gpswd")==0 ){
                   System.out.print("COOOOOOL");
              else{
                   System.out.print("BAD");
         public void textValueChanged(TextEvent te){
              String foo = usr.getText();
              System.out.print("\n\nevent please\n\n"+foo+" +"+usr.getSelectedText());
         public void paint(Graphics g) {
              logo = getImage(getCodeBase(),"logo2.gif");
              g.setColor(Color.WHITE);
              g.fillRect(0,0,1000,625);
              g.drawImage(logo, 0, 0, this);
              g.setFont(new Font("SansSerif", Font.ITALIC, 20));
              g.setColor(Color.BLUE);
              text = "Welcome to AMPD Timecard!";
              g.drawString(text, 300, 255);
              authenticate(g);

  • Question about making printible reports by reading data from database

    We have a pressure test system which we want analyze and plot the instant pressure values in a pre-defined time interval. After each test we want the record the test results along with the other information(date, time, operator name, test no, product type, product number, etc.) added by the system operator. The data will be recorded to an access data base. Doing that, we want to make test results archive which we can make search within, to list the past test results, searching by date, seraching by product number, or searching by any other information in the database. Plus, in the future, we want to be able to take reports of these past test results, including the pressure/time graph and other information added by the system operator. Also we want to set the report format.
    My question is, is it possible to do this with LABVIEW 8.2? Do we need any toolkits or add-ons?
    Regards

    Hi, Hasan.
    That would be an excellent use of LabVIEW. At the very least, you'll probably want to get the Database Connectivity Toolkit, and depending on your needs you may also want the Report Generation Toolkit. There are a lot of tools in the LabVIEW Development Environment for generating reports dynamically, but the Report Generation Toolkit includes a lot of advanced functionality not included in regular LabVIEW installations.
    That said, however, I really recommend you speak with one of our sales representatives to make sure you have everything you need. Since I know so little about how you'd be implementing each step of that process, I'm reluctant to guarantee it, and one of our representatives can tell you with much more certainty. You can get in touch with one from ni.com/contact.
    Good luck! Have a nice evening.
    Sarah K.
    Search PME
    National Instruments

  • Read data from database  write it in excel sheet throw java

    hi
    i wanna to read database table & write it contain in excel sheet how i will do this connectivity between jdbc & excelDB how i will do this
    tell me
    sandeep patil
    [email protected]

    Read Suns JDBC Tutorial, then if there is already an Excel spreadsheet set up to use as an ODBC datasource use JDBC and the JDBC/ODBC bridge. If there is not an already setup ODBC Datasource then Google POI HSSF and/or JExcel to do the Excel part.

  • Problem reading data from a file

    this is inside a servlet.
    Re: servlet question
    Author: gramberto
    In Reply To: servlet question Oct 1, 2004 10:24 AM
    Reply 6 of 6
    I'm getting the following errors:
    java.util.NoSuchElementException     at java.util.StringTokenizer.nextToken(StringTokenizer.java:259)     at myClass.readFile(myClass.java:387)     at myClass.doPost(myClass.java:421)I am reading a file of the form:
    Blah|blah2||
    '|' is the delimiter. A null would just have another |
    Here is my code:
    public void readFile(HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
              PrintWriter out = response.getWriter();
             String row;
             BufferedReader infile1 = new BufferedReader(new FileReader("c:\\file1.txt"));
             response.setContentType("text/html");
             String FName="",MName="",LName="",Sex="",Street1="",Street2="",City="",State="",Zip="",PhoneLocalCode="",PhoneAreaCode="",PhoneLastCode="",Email="",OtherInfo="";
            try {
                    while ((row = infile1.readLine()) != null)
                      StringTokenizer in_str = new StringTokenizer(row, "|");
                      FName = in_str.nextToken();
                      MName = in_str.nextToken();
                      LName = in_str.nextToken();
                      Sex = in_str.nextToken();
                      Street1 = in_str.nextToken();
                      Street2 = in_str.nextToken();
                      City = in_str.nextToken();
                      State = in_str.nextToken();
                      Zip = in_str.nextToken();
                      PhoneLocalCode = in_str.nextToken();
                      PhoneAreaCode = in_str.nextToken();
                      PhoneLastCode = in_str.nextToken();
                      Email = in_str.nextToken();
                      OtherInfo = in_str.nextToken();
                 } catch (IOException ioException) {
                   out.println("Error: "+ioException);
                 out.println(FName);
                 out.println(MName);

    Well, you are probably passing in a line that is tokinized into less than 14 tokens.
    Add some debug output that prints the line that you are tokenizing.
    Use hasMoreTokens and countTokens to determine if it is ok to call nextToken or if you are already out of tokens.
    E.g. you could do something along these lines:
    fixed token count formatprivate void tokenize(final String line)
      final StringTokenizer st = new StringTokenizer( line, "|" );
      if ( st.countTokens() != 14 )
         throw new RuntimeException("Invalid token count: " + st.countTokens());
      FName = st.nextToken();
    }variable token count formatprivate void tokenize(final String line)
      final StringTokenizer st = new StringTokenizer( line, "|" );
      if (st.hasMoreTokens())
        FName = st.nextToken();
      if (st.hasMoreTokens())
        MName = st.nextToken();
    }

  • Problem Reading Data From An Excel Spreadsheet

     

    HI,
    Have u set classpath correctly, i mean does this pakage appear in the class path of ur sever. If not include it in the classpath of the sever or the web-app that u have created. From their only can it include it.
    Take care
    Kunal

Maybe you are looking for