What variable type for database
Hi to all..
I would like to ask advice on what is the best type of variable to store and manage data. I am basically trying to build a small database of customer, names, address, tel number etc. The data is read and then saved into a simple excel or csv file. All is run locally, no need to connect to the web etc..
I had started with a two dimensional array, but then I realise that I cannot Re-dim the array, as records are added or deleted. So I found something called Arraylist, but I have problem in working in two dimensions (maybe that's why it is called a list?).
can anyone suggest what is the best structure for this, bearing in mind that the records are then shown in a jtable, as a list (with multiple columns).
thanks for your help
hey!!!
suggestion of jverd (above) is a very good suggestion and you should hava a look at it. keeping the records in a seperate object would be the best. technically you can then make an array of those objects and then write them into file via ObejctOutputStream.
but i think that what you want is to have the data in a 2-dimensional array so you can then create JTable.
well then you will, most probably, need to look into table models and create your own table model (extension of abstract table model) and then do operations on it.
sample:
import java.util.*;
import javax.swing.*;
import javax.swing.table.*;
import java.awt.*;
import java.awt.event.*;
public class neco extends JFrame implements ActionListener{
private JScrollPane scroll = new JScrollPane();
private JButton btn = new JButton("add row");
private JTable tbl;
public neco(){
Object[] cols = {"first name","last name","phone number"};
Object[][] data = {
{"first name","last name","phone number"},
{"second first name", "second last name","second phone number"}
Container cn = this.getContentPane();
cn.setLayout(new FlowLayout());
cn.add(scroll);
scroll.setViewport(this.getPort(tbl = new JTable(new MyTableModel(data,cols))));
cn.add(btn);
btn.addActionListener(this);
cn.validate();
private JViewport getPort(JComponent comp){
JViewport port = new JViewport();
port.setView(comp);
return port;
public void actionPerformed(ActionEvent ae){
if(ae.getSource() == btn){
MyTableModel mtm = (MyTableModel)tbl.getModel();
mtm.addRow(new Object[]{"new first name","new last name","new phone number"});
scroll.validate();
public static void main(String[] vik){
neco n = new neco();
n.setSize(800,600);
n.setVisible(true);
n.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
class MyTableModel extends AbstractTableModel{
Object[][] data;
Object[] cols;
public MyTableModel(Object[][] data, Object[] cols){
this.data = data;
this.cols = cols;
@Override
public String getColumnName(int col){
return cols[col].toString();
public void addRow(Object[] row){
Object[][] newData = new Object[this.getRowCount() + 1][this.getColumnCount()];
//now copy the old object[][] array into this new one
for(int count=0;count<this.getRowCount();count++){
newData[count] = data[count];
//and now add the new row
newData[newData.length - 1] = row;
//make data our newData
data = newData;
fireTableRowsInserted(0,data.length - 1);
public Object getValueAt(int row, int col){
return data[row][col];
public int getColumnCount(){
return cols.length;
public int getRowCount(){
return data.length;
}in your (MyTableModel) you can add methods for getting rows, or column, or whatever you want and then you will have all the data that you need.
hope this will help
v.v.
Similar Messages
-
Adobe Community Help search box is black. Can't see what I type for inquiry.
When I click on help in Photoshop or Bridge
CS5 the Community Help search box appears, but the entire left column is black. I can't see what I type or see any results, although they're there (I can click at random in that black column and I get some result on the right). Anyone know how to fix that?I uninstalled Air and Flash, then downloaded and reinstalled each of them.
Clicking on Help in Bridge now results is black backgrounds on the top row (left and right), and when I type in a search term it appears in white. However, I get no results from my inquiry (I typed in "photo", among others). Anything else I could try? Help was never very helpful, but at least it was someplace to start.... -
What java type for SelectManyCheckbox
I have a problem with the SelectManyCheckBox component.
I don't know which Java type I should take for the value attribute of the SelectManyCheckbox. I tried a List, but then the JSF Page isn't executed, when I press the Button. Although I have a t:message Tag no messages are shown. Simply nothing happens.
Here is my code snippet:
<h:selectManyCheckbox id="Datenarten" required="true" value="#{newPartnerDto.datenarten}">
<f:selectItems value="#{queryHelper.datenartContact}"/>
</h:selectManyCheckbox> In the backing bean i have
private List datenarten;
and setter and Getter Methods for this.If I use a Long[] instead of a List, the page is executed...
Can anybody tell me, what's wrong?
regards,
AndyThe objects that f:selectItems should return in its collection is:
javax.faces.model.SelectItemfor example
returnList = new ArrayList(3);
returnList .add(new SelectItem(
new Integer(int),
name1);
returnList .add(new SelectItem(
new Integer(int),
name1);
returnList .add(new SelectItem(int,name1); -
What battery type for Tungsten E2?
1) Could someone tell me what battery I need for the Tungsten E2; mine depletes quickly and is now on electrical charge.
2) How mch time do I have to replace it when in the process of battery exchange?. Have Hot synced data to computer, but hope not to lose it on Palm during the process..
Thanks so mch. MC
Post relates to: Tungsten E2Your Palm has flash memory, that means that when he battery dies or is disconnected, you won't lose your data. Basically, you have eternity to replace it.
As for battery type, you can get one at usedpdaparts.com, eBay or amazon.com under "tungsten e2 battery." (Keep in mind they come in slightly different capacities, the stock one, the high capacity one etc (1050 mAh, 1100 mAh, etc.) Another idea is to buy a decent condition e2 or model with a compatible battery and swap it in. I noticed that an entire PDA seems to be more cost effective than buying individual parts, but thats just my experience.
webosnation.com is another option for help. -
What variable type to use??
i need to perform calculations on various numbers ranging from 0 to as big as possible.i also need to perform divide operations on these numbers and i need the result to be very accurate including decimal points.
example: (24 * 1000000) \ 35250
what type should i declare these numbers as??
i have tried BigDecimal but it always rounds the result to a whole number??BigDecimal setScale throws an ArithmeticExpression exception if roundingMode==ROUND_UNNECESSARY and the specified scaling operation would require rounding.
since my calculations would give results with many numbers after decimal point would it require rounding?? -
What cable type for connecting with gigabit port
What kind of lan cable that I should use for connecting with gigabit port from Time Capsule to get the fastest transfer rate. And what is the maximum rate MB/sec that could be?
You can use CAT5 or CAT6.
max transfer rate is:
Fast Ethernet has a theoretical speed of 100 Mbits/sec (12 MB/sec), while Gigabit Ethernet has a theoretical speed of 1000 Mbits/sec (120 MB/sec). That suggests a double speed advantage of Gigabit Ethernet over USB (60 MB/sec), but neither protocol hits its maximum. In reality, a typical USB connected disk is roughly equal to or lesser than the throughput of a shared drive attached over a Gigabit Ethernet network.
Over wireless network:
- 802.11b has a theoretical speed maximum of 11 Mbits/sec with a typical transfer rate of around 4.5 Mbits/sec (0.5 MB/sec) with an ideal signal.
- 802.11g has a theoretical speed maximum of 54 Mbits/sec, with a typical transfer rate of around 23 Mbits/sec (2.5 MB/sec) with an ideal signal.
- 802.11n has a theoretical speed maximum of 300 Mbits/sec, with a typical transfer rate of around 74 Mbits/sec (9.25 MB/sec) with an ideal signal. -
Hi All,
We are using 11.2.0.2 Database.
A customer of ours has sent us a copy of their database in rman format.
There are no instructions with the files.
The files sent are something that looks like it might be a control file, a number of backup files of varying sizes that look like backed up tablespaces / other files, and a final small file that has a suffix of bck.
While we use rman for backup and recovery, we were suprised to be sent a database in this format with no instructions of how the rman backup was created. Generally we assumed that an rman back is best used to recover the database it was taken from rather than create a new one.
If we'd been sent an export, it would have been easier to know what to do with it.
Without knowing anymore than the above, does it seem possible to build a database from the files we have been given?
Can we examine the control file and figure out what the rman command was that created the file set we received?
thanks for your help.
TonyI hoppe this help you
Plz post the filenames, do you have de DBID ?, wich O.S. do you have ?
The FORMAT clause can use substitution variables to differentiate backupsets by
database, by piece, and so forth. Here are a few sample substitution variable types:
■ %d Database name
■ %e Archived log sequence number
■ %f Absolute file number
■ %F Combines the DBID, day, month, year, and sequence number, separated
by dashes
■ %c Copy number for multiple copies in a duplexed backup
■ %I Database identifier (DBID)
■ %n Database name padded to eight characters
■ %p Piece number within the backupset
■ %s Backupset number
■ %t Backupset timestamp
■ %U System-generated unique filename (the default)
Restore DB onto New Host
1. Configure environment variables on the new host.
2. Connect to the new target database with NOCATALOG.
3. Set the DBID.
4. Start the instance with NOMOUNT.
5. Restore the SPFILE from backup.
6. Shut down the new instance.
7. Edit the PFILE.
8. Start the instance with NOMOUNT (again) .
9. Create an RMAN RUN block to restore the control file.
10. Create an RMAN RUN block to restore and recover the database.
11. Open the database with RESETLOGS.
J.A. -
Use of variable types and rounding...
I'm kinda confused on what variable types to use. I want it so that when I divide two numbers, it'll either round up or down, and give me a rounded number w/o a decimal.
Examples...
184/2683=7
164/2683=6
I have been fiddling with it for a while now, and I keep getting rounded down numbers, even if the decinal is more than .5. Thanks in advance!184 / 2683 = 0.068579947819604919865821841222512 -> 0.07
164 / 2683 = 0.061125605665300037271710771524413 -> 0.06
Use Math.rint (please read the javadocs...) and some scaling (multiply by 100.00, divide by 100.0 etc).
Beware - when printing your result could be:
0.070000000000001
or
0.069999999999998
instead of the expected value 0.07
for instance, due to the properties of floating-point arithmetic. If you want to round the number only for displaying it, use java.text.DecimalFormat or java.text.MessageFormat. -
Can someone tell me what variable type 16396 is?
I am receiving this error after the script has been called and ran, no probelms while the script is executing. After the script has finished is when this error presents itself.
Thanks for any help.
Paul LindemuthHi Paul,
I've never seen or head of this error message before. Can you send over your VBScript so we can reproduce the error here as see what's going on?
Regards,
Brad Turpin
DIAdem Product Support Engineer
National Instruments -
Not sending what I type on Apple Bluetooth keyboard
I have an iPad Air running 8.0.2 and an Apple Bluetooth keyboard. When I type on the keyboard, I don't get what I type for many characters. For example, if I type a "d", I consistently see "ds" on the screen. When I type "q", I consistently see "qz". sometimes it just starts sending "'" repeatedly without me typing anything.
I have tried deleting the keyboard from the Bluetooth (forget this device), taking the batteries out of the keyboard, turning the iPad all the way off, restarting the iPad, putting the batteries back in the keyboard, pairing again, and see the exact same behavior.
I'm seeing this while typing into an email.
I started in 8.0.0 with the same problem and then upgraded. I had not tried to use this keyboard for a while. The batteries were dead, so I put in new ones, paired it again (having removed the pairing earlier) and saw this problem.
Is this some setting that is incorrect? How do I correct this.thats weird - after iOS8 upgrade, whenever i click on the edit box and start typing nothing happens until I repeatedly tap on the edit box. I find that tapping faster eventually fixes this kb/typing issue
-
ORA-04054 : using variable substitution for the database link name
Hi,
I need to use variable substitution for the database link name.
Here is my command :
declare
GET VARCHAR2(50);
begin
select OIA_GET_DESIGNATION into GET from INFODRI.OMA_IN_ARTICLES;
for rec in (select * from [email protected]_GET_DESIGNATION)
LOOP
dbms_output.put_line('TEN_CODE vaut : '||rec.ten_code);
END LOOP;
exception
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('ERREUR ORACLE DETECTEE : '||rec.OIR_CUR);
DBMS_OUTPUT.PUT_LINE('Message Erreur : '||SUBSTR(SQLERRM,1,245));
:crd := -1;
end;
When I run this programm, I receive the error :
ORA-04054: database link REC.OIA_GET_DESIGNATION does not exist
When I replace :
for rec in (select * from [email protected]_GET_DESIGNATION)
by :
for rec in (execute immediate 'select * from tensions@'||rec.OIA_GET_DESIGNATION)
I receive the error :
PLS-00103 : Encountered the symbol "IMMEDIATE" while parsing.
What can I do to resolv my problem ?
Regards,
RachelWhat is the name of the DB Link and the name of the object you are selecting
from?
I find it easier to create a view on the remote object then use that in selects.
e.g,
Link Name = MyLink
Object_name = Addr_Loc
create or replace VIEW Rem_Addr_Loc AS
select * from addr_loc@mylink;
In the code I then use the view
begin
for C_Rec in (select * from Rem_Addr_loc)
loop
dbms_output.put_line('Rec: '|| C_Rec.Col1);
end loop;
end; -
What is the logical message type for Inbound Credit Memo (MM)
Hi Folks,
What is the logical message type for Inbound Credit Memo (MM)
Plz explain.
Thanks,
MattHi Mat,
The logical message types are as follows.
/DSD/HH_CREDITDATA DSD Credit Exposure and Credit lLmit
CREADV Credit memo display
CRESTA Copy credit status (DebtorCreditAccount)
SBINV Credit memo procedure with invoice creation
SBWAP SD Credit Memo Procedure with Automatic Postin
You can search for message types in database table EDMSG.
Regards,
Vimal. -
What is the data type for time and what to insert
Hi there
i had two attributes in a table called start_time and end_time and i want to insert time into these attrbutes e.g 10:00 and 11:00
How do i do that
what is oracle's built-in type for time???
adn how do i insert values in the table(i.e the format)
thanksThere is not Oracle type that has just a time. The DATE and TIMESTAMP data types include both the date and the time (TIMESTAMP has millisecond resolution and has optional timezone support). If what you're really interested is a time interval (i.e. 1 hour), there are some INTERVAL data types.
You have a lot of options for how to specify dates and timestamps along with format masks.
Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC -
No default driver for database type: jdbc:weblogic:jts problem
Here is what we are trying to do. We have two Weblogic servers running on 2 different
machines. Lets call them A and B. A has 2 beans lets call them Abean1, Abean2.
and B has one bean called Bbean1. Now Abean1 has to contact Bbean1 which in turn
has to contact Abean2 (dont ask why :) . We are running into transcation issues
namely ' No default driver for database type: jdbc:weblogic:jts'. Abean1 has Container
transaction and Bbean1 has Bean managed transaction. We set Abean2 methods transaction
attribute to NotSupported. However no luck. Has anyone come across this kind of
situation? Any clues as to what might be going on? Abean1 can contact Bbean1 successfully
ie if we dont force Bbean1 to contact Abean2. However when Bbean1 tries to contact
Abean2 thats when the fun starts.
thanks
Report to [email protected] It could be related to some JTS driver bugs that
have been / are being fixed recently.
Regards,
Priscilla
musman <[email protected]> wrote in message
news:3bd74f33$[email protected]..
>
> Here is what we are trying to do. We have two Weblogic servers running on
2 different
> machines. Lets call them A and B. A has 2 beans lets call them Abean1,
Abean2.
> and B has one bean called Bbean1. Now Abean1 has to contact Bbean1 which
in turn
> has to contact Abean2 (dont ask why :) . We are running into transcation
issues
> namely ' No default driver for database type: jdbc:weblogic:jts'. Abean1
has Container
> transaction and Bbean1 has Bean managed transaction. We set Abean2 methods
transaction
> attribute to NotSupported. However no luck. Has anyone come across this
kind of
> situation? Any clues as to what might be going on? Abean1 can contact
Bbean1 successfully
> ie if we dont force Bbean1 to contact Abean2. However when Bbean1 tries to
contact
> Abean2 thats when the fun starts.
>
> thanks
-
Database Column Type for Rich Text Editor
Hi,
I have a page item as Rich Text Editor. Now I want to store the data in tables in the same format as user entered in the page item.
What would be the database column type for that?
Thanks,
MehabubMehabub Sheikh wrote:
I have a page item as Rich Text Editor. Now I want to store the data in tables in the same format as user entered in the page item.
What would be the database column type for that?As usual, the answer is "It depends".
In this case it depends on the nature and size of the content. For content up to 4000 bytes in length, use VARCHAR2 or NVARCHAR2 (depending on the DB character set and globalization requirements), for content of longer length use CLOB or NCLOB (again depending on DB characterset and your globalization requirements).
Note the effect of DB character set on the number of characters you can store in a VARCHAR2 or NVARCHAR2 column, and the overhead of HTML tags generated by formatting in the Rich Text Editor.
Maybe you are looking for
-
I have installed iBooks on both my iMac (main library) as well as on my iPad Mini Retina. I can't seem to find where to see the total number of books in each library? Can anyone enlighten me please? I can see the covers, lists etc. but nowhere how ma
-
On my Mac, after the installation i get this error when i start - "Premiere Elements 13.0 has encountered an error. [/Adobe/pre/main/MediaCore/ASL/Foundation/Make/Mac/../../Src/DirectoryRegistry.cpp-283]" any ideas how to fix this, i don't know or ha
-
My apps are white boxes (well about half of my apps) after I did a sync yesterday
I synced my daughters 3rd gen to my itunes yesterday, adding music & apps. After sync finished, everything was fine...all the apps had the appropriate pic. I powered it off. My daughter powered it on about 2 hours later and now about half of the apps
-
Transacation log in 2 client after Change PI default client (Note 940309)
Hi, I have changed the PI default client follow the SAP note 940309, and then all the transaction working fine, but then i realize that the xml transaction log save in both client. (001 and new client(220)). SXMB_MONI - Monitor for Processed XML Mess
-
Im looking to purchase an eMac from a use computer store. Will my 1st gen Shuffle work with the eMac? Says its running 10 OS. Is this 10 OS X? Thanks!!