How to put datas from database in html�s forms?
Does anyone have any idea how to put datas from the database using JSP???
One option: put your data into a JavaBean and then put that into the session. You can then access it from your JSP. You can access the properties of the bean using the basic JSP scripting elements, or if you want to get fancy, both JSTL and Struts have a bunch of custom tags for working with JavaBeans.
Similar Messages
-
How to put data from database into array
I need to answer hot to put data from database directly into array.
I tried like the code below but the error message said: java.lang.ArrayIndexOutOfBoundsException: 0, and it points to this line: numbers [row][0]= rs.getString("ID");
Hope you can help.
ResultSet rs = stmt.executeQuery(query);
int row=0;
String [] [] numbers=new String [row][10];
// output resultset
while ( rs.next() )
numbers [row][0]= rs.getString("ID");
numbers [row][1]= rs.getString("name");
row++;
// close resultset
rs.close();
thanks,DeviThe exception is been thrown simply because you assigned '0' to the 'row' variable, indicating a zero length of the array. In fact you should assign the row count to it.
After all, don't do that. Make use of the Collection framework and map the ResultSet to a Collection of DTO's.
List<User> users = new ArrayList<User>();
while (resultSet.next()) {
User user = new User();
user.setID(resultSet.getString("ID"));
user.setName(resultSet.getString("name"));
users.add(user);
} -
Script to put Datas from Database to TextInput
Hello,
As it is said in the title, I would like to put Datas from Database to Textinput. Here's my application :
Well, what I want to do is when you click on the lines in the Datagrid, the "Nom Area" is completed by the Name in the Datagrid, the "adresse area" by the adress in the Datagrid ...
Can someone help me ? please
Thank youHere's my code
<code>
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:fourD="http://www.4d.com/2007/mxml" layout="absolute" viewSourceURL="srcview/index.html" backgroundGradientAlphas="[1.0,1.0]" backgroundGradientColors="[#EDE3E3, #555555]" color="#040404" height="899">
<mx:Script>
<![CDATA[
import fourD.sql.*;
import mx.controls.Alert;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
[Bindable]
private var _resultSet:SQLResultSet;
// Initialisation de la connection
private function connectHandler(event:Event):void
fourDSQLService.execute("SELECT * FROM clients"); }
private function resultHandler(event:ResultEvent):void
if(event.result != null) { _resultSet = event.result as SQLResultSet; } }
// En cas d'erreur
private function faultHandler(event:FaultEvent):void
var zeError:String= "Error #" + event.fault.faultCode;
// Message d'erreur
Alert.show(event.fault.faultString,zeError); }
]]>
</mx:Script>
<!-- Declaration du serveur SQL-->
<!-- Connection automatique au dŽmarrage de l'application (login/mdp)-->
<!-- ImplŽmentation des fonctions -->
<fourD:SQLService id = "fourDSQLService"
host = "127.0.0.1"
userName = "sqlUser"
userPassword="sql"
autoConnect="true"
result = "resultHandler(event)"
fault = "faultHandler(event)"
connect="connectHandler(event)"
/>
<!-- Declare the 4D datagrid; It is also possible to use Flex embed datagrid -->
<!-- Bind datagrid source to SQLresultSet coming from 4D-->
<fourD:DataGrid id="contacts_dg"
dataProvider="{_resultSet}" x="10" y="207" width="737" height="397"
/>
<mx:Button x="588" y="627" label="Ajouter" id="btnAjouter"/>
<mx:Button x="666" y="627" label="Supprimer" id="btnSupprimer"/>
<mx:Text x="10" y="10" text="Nom" />
<mx:Text x="10" y="36" text="Secteur d'activitŽ
"/>
<mx:Text x="10" y="62" text="Groupe"/>
<mx:Text x="10" y="112" text="Responsable commercial"/>
<mx:Text x="10" y="88" text="Adresse"/>
<mx:Text x="416" y="88" text="Ville"/>
<mx:Text x="595" y="88" text="Code Postal"/>
<mx:Text x="10" y="138" text="Responsable production
"/>
<mx:Text x="416" y="112" text="Responsable 3"/>
<mx:Text x="416" y="138" text="Responsable 4"/>
<mx:Text x="624" y="10" text="Code"/>
<mx:RadioButton x="610" y="34" label="Client"/>
<mx:RadioButton x="675" y="34" label="Prospect"/>
<mx:TextInput x="48" y="8" width="568" id="nomArea" />
<mx:TextInput x="117" y="34" width="485"/>
<mx:TextInput x="666" y="8" width="81"/>
<mx:TextInput x="675" y="86" width="72"/>
<mx:TextInput x="63" y="60" width="684"/>
<mx:ComboBox x="157" y="110" width="251"></mx:ComboBox>
<mx:ComboBox x="157" y="140" width="251"></mx:ComboBox>
<mx:ComboBox x="512" y="110" width="235"></mx:ComboBox>
<mx:ComboBox x="512" y="140" width="235"></mx:ComboBox>
<mx:Text x="317.5" y="161" text="Liste Clients" fontSize="19"/>
<mx:TextInput x="63" y="86" width="345"/>
<mx:TextInput x="452" y="86" width="135"/>
</mx:Application>
</code> -
How to retrive data from database views or projection views
how to retrive data from database views or projection views
Hi chintam,
1. Very simple
2. Just like normal select statement.
3. Select * from VIEWNAME.
4. (Instead of the tablename, we just have to give the viewname)
regards,
amit m. -
How to display data from Database individually??? Anyone can help ?
HI,
i i had select a row of data from database using ,
/* Query * From Table RESOURCEORDER where po = selected no and project = selected project */
public ResultSet getAllData() throws SQLException
getConnection();
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM RESOURCEORDER WHERE PROJECT = '" + getSelProject() + "' and PURCHASEORDERNO = '" + getPo() + "'" );
return rs;
After that , how do i display the data individually ?
Eg select data is ('projectA','7891203-1', '10-4-2005','lcd',2000,'121-45217-8','electrical','pending','donwong')
i want to display them individually, like this in a page
Projectname: /* should display the Project A*/
P.O no:
Date:
Order:
Cost:
Acc no:
Type:
status:
Orderedby:
Can anyone help ? cos i'm new to JSP ......Thanks alot!!!!!
Regards,
khimI assume PO being a unique key, will always return 1 row from db.
public String[] getAllData() throws Exception
getConnection();
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM RESOURCEORDER WHERE PROJECT = '" + getSelProject() + "' and PURCHASEORDERNO = '" + getPo() + "'" );
String [] returnValue = new String[9];
while(rs.next())
returnValue[1] = rs.getString("colname");
returnValue[2] = rs.getString("colname");
///and so on
return returnValue;
}Once you get that you could individually view it by setting a loop to run through the returned array.
Hope it helps -
How to fetch data from database in javafx 2.2 table which is editable.
Dears!
I want to fetch data from database in javafx 2.2 tableformat with jdbc , which is also editable and i can add more records in this table also.
Can anybody help meI can vaguely recall some sort of JavaFX database connectivity feature, I'm not sure if it's valid anymore.The link is based on JavaFX Composer which only applied to NetBeans 6.9 and JavaFX 1.x (both of which are now dead techs).
There is a good chance you will have to write your own. There are several blogs describing other peoples' work. You could probably use them as a reference.Here is Narayan's basic [url http://blog.ngopal.com.np/2011/10/19/dyanmic-tableview-data-from-database/] tutorial for displaying data from a database in a TableView, you'll need to look elsewhere for the editing portion.
The [url http://docs.oracle.com/javafx/2/ui_controls/table-view.htm]JavaFX TableView tutorial gives info about how to handle edits in a TableView, but you will need to tie the updates back to the database yourself.
It is possible that [url http://www.javafxdata.org/]DataFX may provide some facilities to help support you. -
How to extract data from database to XSLT?
I want to generate a report by XSLT, but the data is extracted from the database. I will use Access/SQL server for my database. Can i write SQL in XSLT to extract data from database? Have any sample code or reference website to show how it work?
THXfor example: "SELECT code, name FROM TABLE FOR XML RAW"
String xml = null;
if(rs.next()){
xml = rs.getString(1);
}You will get xml string something like this:
<row empID="1234"/><row empID="1235"/>
You can construct a DOM using this xml data and operate on it.
However you may explore more on resulting xml format.
A different SQL Query (rather than using XML RAW) may give output in a more desired format. -
How to retrieve data from database to the structure(complicated)
Hello everyone:
I want to retrieve data from database to the structure. but the structure defined like this below:
TOLERANZOB LIKE QAMV-TOLERANZOB
TOLERANZOB1 LIKE QAMV-TOLERANZOB
so how can I retrieve the data from the database ? make sure that the two fields contain data both.
Thanks in advance .
Regards
NickHi Nick,
To retreive data for TOLERANZOB from QAMV,
If you know the key fields then use
SELECT SINGLE TOLERANZOB FROM QAMV INTO TOLERANZOB WHERE keyfields.
else, you can use
SELECT TOLERANZOB FROM QAMV UPTO ONE ROWS INTO TOLERANZOB WHERE....
Once you retreive the data using the select query, you can check if it is initial and if not move the data from TOLERANZOB to TOLERANZOB1.
<b>Reward points for helpful answers.</b>
Best Regards,
Ram. -
Help , How to get data from database using recordset with UI API
I want to get a data from database
when I want to create recordset i notice that UI API didn't has record set
so I created recordset using DI API (SAPbobscom.recordset and SAPbobscom.company)
======================================================
Dim oCompanyUI As SAPbouiCOM.Company <<UI API
Dim oRecSet As New SAPbobsCOM.Recordset << DI API
Dim oCompanyDI As New SAPbobsCOM.Company << DI API
'=====================================================
oCompanyDI.Connect
Set oRecSet = oCompanyDI.GetBusinessObject(BoRecordset)
oRecSet.DoQuery ("SELECT T0.CardCode, T0.CardName FROM OCRD T0")
SBO_Application.MessageBox oRecSet.Fields.Item(1).Value
======================================================
but I got an error it said "you are not connected to company"
I'm really don't have an idea about how to get a data from using UI API (exp I want to get a date or costumer code)
can someone help me please, I really need it
Thanksyou need a single sign on
Dim oDICompany As SAPbobsCOM.Company
Dim sCookie As String
Dim sConnStr As String
Dim ret As Integer
oDICompany = New SAPbobsCOM.Company
sCookie = oDICompany.GetContextCookie
sConnStr = SBO_Application.Company.GetConnectionContext(sCookie)
If oDICompany.Connected Then
oDICompany.Disconnect()
End If
ret = oDICompany.SetSboLoginContext(sConnStr)
If Not ret = 0 Then
SBO_Application.MessageBox("set Login Context failed!")
Exit Sub
End If
ret = oDICompany.Connect()
If Not ret = 0 Then
SBO_Application.MessageBox("Company Connect failed!")
End If -
Oracle form: how to retrieve data from database to pop list
I have problem in retrieving data from database to item list in
oracle forms.
Can anyone help me.
thanks.The next is an example but you can find this information in
Forms Help:
DECLARE
G_DESCS RECORDGROUP;
ERRCODE NUMBER;
rg_id RECORDGROUP;
rg_name VARCHAR2(40) := 'Descripciones';
BEGIN
rg_id := FIND_GROUP(rg_name);
IF Id_Null(rg_id) THEN
G_DESCS := Create_Group_From_Query (rg_name, 'SELECT
DESCRIPCION DESCRIPCION, DESCRIPCION DESC2 FROM FORMAS_PAGO);
ERRCODE := POPULATE_GROUP(G_DESCS);
POPULATE_LIST('FORMAS_PAGO.CMBDESCRIPCION',G_DESCS);
END IF;
END;
Saludos.
Mauricio. -
How to download Data from Database directly into excel
I have a requirement to download very large quantity of data from database into Excel file.
But condition is excel file should have only 65,536 rows in a single spread sheet(that's the limit i suppose),if i have more data points(rows) than it should be stored into different spreadsheet.......this continues so there can be many spread sheets in a single excel file.
Data size can be 1 GB or more.
Also specific naming conventions need to be followed for giving name to excel as well as different spread sheets in it.
Please see if someone could help me out.Thanks for ur reply,
But my requirement is to call "download to excel" method,in a java program on click by user for downloading an excel sheet on his machine.
This is be done as part of a web application which is to be made (so can't open the excel first) -
How to populate data from table into datagrid in form
hi there. may i know how to populate data from a table into a datagrid? i have created a datagrid in a form using OLE's microsoft datagrid. i'm having problem to populate data from table into the grid. can i know how to do that? thanks
Not exactly. I want to enter input from form and the user can have all options to choose i.e. HIGH, MEDIUM or so on.
Suppose, you have option to select HIGH, MEDIUM or LOW and you can see all these options together. You select LOW and when you save, it is saves in the table as a value. So when you view the table again, it will show LOW as active and HIGH and MEDIUM are null. -
How to fetch data from Database using SUP MBOs
I'm learning to develop blackberry apps using SUP.I am new to both blackberry api and SUP.
I need to make a login page for a Student and then validate the username and password entered using data from a database.
I need to check the database for the username and password entered. What should be my next step? How do i get this data from the database. Using findAll() method is not working . Do i need to connect to SCC or unwired server first. If yes , then someone please provide a sample code for it.Hi!, I see your code and I see that you have a fee errors, try to use this:
import java.text.*;
import java.sql.*;
import java.util.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.OutputStream;
* NOTE: You must put the try-catch and your sql code into the get method
/** Servlet program to take fetchdata from database and display that on the broswer*/
public class Fetchdata
extends HttpServlet {
String query = new String();
String uid = "ashvini";
String pwd = "******";
public void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException, Exception {
try {
Connection con = null;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url = "jdbc:odbc:Testing";
con = DriverManager.getConnection(url, uid, pwd);
Statement s = con.createStatement();
query = "select * from gowri.msllst1";
ResultSet rs = s.executeQuery(query);
response.setContentType("text/html");
ServletOutputStream out = response.getOutputStream();
out.println("<HTML>" + "<BODY BGCOLOR=\"#FDF5E6\">\n" +
"<H1 ALIGN=CENTER>" + title + "</H1>\n" +
"<table>" + " <th>ITEM Code</th>");
while (rs.next()) {
out.println("<tr><td>" + rs.getString(1).trim() + "</td></tr>");//I change </tr></td> for </td></tr>
} //end of while
out.println("</table></BODY></HTML>");
catch (Exception e) {
System.out.println(e);
} //end of doGet method
}I hope this help you :) -
How to fetch data from DataBase using Servlet ?
Hi all,
Till now, i was just sending values from web page and receive the data in excel format using servlets.
But, now, i want to fetch data from data base. I will be giving inputs in the web page(for the query)....ON click of submit button,
Servlet should be called.
Depending on the input, query has to be executed, and response should be sent to the user.
How to do it?
Code
import java.text.*;
import java.sql.*;
import java.util.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.OutputStream;
/** Simple servlet that reads three parameters from the html
form
public class Fetchdata extends HttpServlet
String query=new String();
String uid="ashvini";
String pwd="******";
try
Connection con=null;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url = "jdbc:odbc:Testing";
con = DriverManager.getConnection(url, uid, pwd);
Statement s = con.createStatement();
query = "select * from gowri.msllst1";
ResultSet rs = s.executeQuery(query);
public void doGet(HttpServletRequest request,HttpServletResponse response)
throws ServletException, IOException
response.setContentType("application/vnd.ms-excel");
ServletOutputStream out=response.getOutputStream();
out.println("<HTML>" +"<BODY BGCOLOR=\"#FDF5E6\">\n" +
"<H1 ALIGN=CENTER>" + title + "</H1>\n" +
"<table>" +" <th>ITEM Code</th>");
while(rs.next())
out.println("<tr><td>" rs.getString(1).trim()"</tr></td>");
}//end of while
out.println("</table></BODY></HTML>");
}//end of doGet method
}catch(Exception e)
System.out.println(e);
It is giving error message as:
C:\Program Files\Apache Tomcat 4.0\webapps\general\srvlt>javac Fetchdata.java
Fetchdata.java:17: illegal start of type
try
^
Fetchdata.java:48: <identifier> expected
^
2 errors
Is this format is correct? am i placing this doGet method at the right place? is my program's logic is correct?
Please help me?
Regards
AShviniThere is some mistakes in ur code.....how can try catch exists outside a function???
make use of try catch isde ur doGet method and put
Connection con=null;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url = "jdbc:odbc:Testing";
con = DriverManager.getConnection(url, uid, pwd);
Statement s = con.createStatement();
query = "select * from gowri.msllst1";
ResultSet rs = s.executeQuery(query);
isdie doGet method, for the time being,
i think u get me..
regards
shanu -
How to Retrieve data from database into another form ?
Good Day!
Am currently new at JSP. I've been studying it for awhile and still getting the hang of it. We are working on a project.
Editing a given data. We have to retrieve the given data and post it to another form "Editing form".
Since we can retrieve data using JSP but how are we going to post it to another form? I mean how are we going to transfer data from one form to another?
Can anyone help me with codes please..The client is a web browser.
The client submits a request (click a link, visit a form)
The server gets to respond to this
- look at request parameters from the client
- access database
- produce resulting html page
- send page back to client.
The standard pattern is to retrieve data from the database in java code, and then load that data into a bean.
You then make that bean available as an attribute
It is then available for use in your JSP - either <jsp:useBean> tag or using ${ELexpressions}
All you can pass from the client to the server is request parameters - which are always strings.
Draw a picture of where the information is, and the information flows. Very rarely does it go directly from one "form" to another.
Cheers,
evnafets
Maybe you are looking for
-
How to make SSIS Read an Excel File?
I've been trying for a while now (won't say how long), to get BIDS to read a very simple Excel file. I'm talking SIMPLE!! No matter what I don, SSIS keeps throwing an error, and of course it doesn't say what the error is, so I can't really debug it
-
I just updated my ipod touch 4 gen and now I cannot add music to it in itunes. The "add to" button is gone. I also lost all of my purchased music and cannot add it back.
-
Tried to update iPhone 5 to latest OS. When I looked at the phone a while later, the screen was dark except for the iTunes icon in the middle of the screen and another icon showing the charger cable and an arrow point to the iTunes icon. Now I'm bric
-
404 error when I try to access OpenDocument on BO XI 3.1
I'm using (HowToViewWebiReports) sample provided by ([SAP Business Intelligence Developer SDK Library|http://www.sdn.sap.com/irj/boc/sdklibrary]) In few words, it lists reports names from my repository and then it builds a URL to view that report usi
-
Hello, When I try to activate transfer rules, I get the following error. 'Error with Content merge: InfoObject XXXX already in use' It says that this infoobject has been used in other transfer rules of the same datasource. Could someone help me out w