This is a duplicate post of one I responded to on 12/4.  Have you done
what I suggested?  What was the result?

 

Tracy

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of deepa_golamudi
Sent: Tuesday, December 05, 2006 1:47 AM
To: [email protected]
Subject: [flexcoders] help in database access

 

Hai everybody,
i am new to flex environment and i am struck up with a prob
i am trying to access Databse using flex and java.
in this situation i am trying to retrieve two of the values from the 
DB based on the primary key and view a column chart based on the two 
values retieved.

i am unable to get the required result.

Pl help me.....

here is my mxml file

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml
<http://www.macromedia.com/2003/mxml> ">

<mx:Script>
<![CDATA[
var userList=0;

function initApp()
{
//alert("Hello World!!");
} 
function log()
{
users.getValid(userid.text); 
}


]]>
</mx:Script>
<mx:Canvas width="236" height="400">
<mx:Button x="80" y="203" id="Register" label="Get Result" 
click="log()" textAlign="center" /> 

<mx:TextInput id="userid" x="31" y="142"/>
<mx:Label x="81" y="102" text="Enter User-Id" height="20" 
width="88" />
</mx:Canvas>
<mx:Model id="results" source="users.getValid.result"/>

<mx:ColumnChart width="100%" height="100%" 
dataProvider="{userlist}" showDataTips="true">

<mx:horizontalAxis>
<mx:CategoryAxis dataProvider="{results}" 
categoryField="results.examid"/>
</mx:horizontalAxis>

<mx:series>
<mx:Array>
<mx:ColumnSeries yField="results.score"/>
</mx:Array>
</mx:series>

</mx:ColumnChart>
<!--Login checking remote object-->

<mx:RemoteObject id="users" source="report" 
result="userList=event.result" fault="alert
(event.fault.faultstring, 'Error')" >
<mx:method name="getValid"></mx:method> 
</mx:RemoteObject>

</mx:Application>

here is my java file

import java.sql.*; 
import java.util.ArrayList;

public class report {



Connect q=new Connect();
public report(){
}




public ArrayList getValid(int num){
ArrayList list1 = new ArrayList();
try{
Connection Conn=q.establish_Connection();

Statement s = Conn.createStatement();
ResultSet rs=s.executeQuery("select 
examid,score from report where userid="+num);
while (rs.next()) {

list1.add(new getreportlistVO
( rs.getInt(1),rs.getInt(2)));

}
s.close();
Conn.close(); 


}
catch(Exception e)
{
System.out.println("TechRP Error : "+e);
}
return list1;

}
public static void main(String Args[])
{
report q=new report();

}
}
here is my VO file pich up the values

import java.util.Random;
import java.io.*;
import java.sql.*;
public class getreportlistVO implements java.io.Serializable
{
int examid,score;


public void setexamid(int eid) {
this.examid = eid;

}

public int getscore() {
return score;
}

public void setscore(int score) {
this.score = score;
}


public getreportlistVO(int examid, int score)
{
this.examid=examid;
this.score=score; 
}

public void printval()
{
System.out.println(examid);
System.out.println(score);
} 
}

Regards..
Deepa

 

Reply via email to