I have to create a view from more than one table in MS Sql Server database, but i am not able to get the correct syntax for the same. need help.
thanks.
I have two panels:
main_panel
child_panel
The main_panel layout is set using:
main_panel.setLayout(flowlayout)
I then added child_panel to main_panel:
main_panel.add(child_panel)
The child_panel gets added to main_panel but its position is at the cross-section of horizontal midpoint and top vertical section of screen. I want child_panel to be at the top left corner, something I could have done by using child_panel.setlocation(a,b) method, if I have set the layout of main_panel as null.
I have used FlowLayout here because I want components in the JPanel to keep
adjusting with the size of JFrame.
So can I add child_panel to main_panel at the exact location I want, even if I set the Layout of main_panel as not null?
I have a class that uses XStream and is used as a transfer format for my application. I am writing tests for other classes that map this transfer format to and from a different messaging standard. I would like to ensure that all getters on my class are called within a test to ensure that if a new field is added, my test properly checks for it.
A rough outline of the XStream class
@XStreamAlias("thing")
public class Thing implements Serializable {
private int id;
private int someField;
public int getId(){ ... }
public int someField() { ... }
}
So now if I update that class to be:
@XStreamAlias("thing")
public class Thing implements Serializable {
private int id;
private int someField;
private String newField;
public int getId(){ ... }
public int getSomeField() { ... }
public String getNewField(){ ... }
}
I would want my test to fail because the old tests are not calling getNewField().
The goal is to ensure that if new getters are added, that we have some way of ensuring that the tests check them.
Ideally, this would be contained entirely in the test and not require modifying the underlying Thing class.
Any ideas? Thanks for looking!
I am reading a BLOB column from a Oracle database, then writing it to a file as follows:
public static int execute(String filename, BLOB blob)
{
int success = 1;
try
{
File blobFile = new File(filename);
FileOutputStream outStream = new FileOutputStream(blobFile);
BufferedInputStream inStream = new BufferedInputStream(blob.getBinaryStream());
int length = -1;
int size = blob.getBufferSize();
byte[] buffer = new byte[size];
while ((length = inStream.read(buffer)) != -1)
{
outStream.write(buffer, 0, length);
outStream.flush();
}
inStream.close();
outStream.close();
}
catch (Exception e)
{
e.printStackTrace();
System.out.println("ERROR(img_exportBlob) Unable to export:"+filename);
success = 0;
}
}
The file size is around 3MB and it takes 40-50s to read the buffer. Its actually a 3D image data. So, is there any way by which I can reduce this time?
So, I've been doing android application tutorials and everytime I create a package, for example the helloAndroid tutorial is com.example.android. When it saves this to src it creates a folder for com, another for example and one last one for android. So it gives me the error "class com.example.android does not exist" because its broken into different folders.
If anyone can help me out please email me at: [email protected]
Thank you very much.
I want to read a big text file, what i decided to create four threads and read 25% of file by each one.
and then join them.
but its not more impressive.
can any one tell me can i use concurrent programming for the same.
as my file structure have some data as
name contact compnay policyname policynumber uniqueno
and I want to put all data in hashmap at last.
thanks
Hello i am new with J2ME polish
Can any one tells that how to debug the J2ME polish MIDlet and how can i show the loges which are generated.
Regards
Dhaiwat
The first index is set to null (empty), but it doesn't print the right output, why?
//set the first index as null and the rest as "High"
String a []= {null,"High","High","High","High","High"};
//add array to arraylist
ArrayList<Object> choice = new ArrayList<Object>(Arrays.asList(a));
for(int i=0; i<choice.size(); i++){
if(i==0){
if(choice.get(0).equals(null))
System.out.println("I am empty"); //it doesn't print this output
}
}
Is it possible to have a static collection as a member of a hibernate entity?
Say I have an object Question:
public class Question {
private String category;
...
}
Would it be possible to populate a static Set<String> that is a distinct set of all categories in the Database? I know I could just query this, but I was wondering if there was a more elegant solution, as it seems like something that other people may have come across.
Reading this
When a bean is a singleton, only one
shared instance of the bean will be
managed and all requests for beans
with an id or ids matching that bean
definition will result in that one
specific bean instance being returned.
Will be managed...
What does that mean?
If there's only one object, than any modification to this object will result in that every another
attempt to get this bean will return a modified instance??
A puzzle from this blog. Similar to SO1445233.
Given the following source listing, explain why the compiler is producing a warning at invocation to the list method and give a solution for removing the warning without resorting to @SuppressWarnings annotation.
public class JavaLanguagePuzzle3 {
public static void main(String[] args) {
list("1", 2, new BigDecimal("3.5"));
}
private static <T> List<T> list(T... items) {
return Arrays.asList(items);
}
}
Warning:
Type safety: A generic array of Object&Serializable&Comparable<?> is created for a varargs parameter
If I have a hash map and iterate over the objects repeatedly, is it correct that I'm not guaranteed the same order for every call? For example, could the following print two lines that differ from each other:
Map<String,Integer> map = new HashMap<String,Integer>()
{{ put("a", 1); put("b", 2); put("c", 3); }};
System.out.println(map);
System.out.println(map);
And is this the case for sets and collections in general? If so, what's the best way in case you have to iterate twice over the same collection in the same order (regardless of what order that is)? I guess converting to a list.
Problem Statement is :
Given 2 Dimensional array, print output for example
If 4 rows and 6 columns, output would be:
1 2 3 4 5 6
16 17 18 19 20 7
15 24 23 22 21 8
14 13 12 11 10 9
I tried it is looking like square within square but when I attempted this problem, I put so many while and if loops but didn't got exact answer. If row and columns increases how to handle it?
This is not homework. I was learning solving complex structure so I need to understand it by some guidance.
Lead in ...
I'm not an expert, by far, in application security via SSL, but am trying to establish a test environment that includes all possible scenarios we may encounter in production. For this I have a tree of Certificate Authorities (CAs) that are the issuers of an assortment of test client certificates, and node/server certificates (complex test environment representing the various published web services and other applications we integrate with).
The structure of these CAs are as follows:
Root CA, which has signed/issued Sub CA1, Sub CA2, and Sub CA3. These subs have then signed/issued all certificates of those various nodes and clients in the environment.
Now for the question ....
In my application's truststore I would like to trust everything signed by Sub CA1, and Sub CA2, but not Sub CA3 (untrusted). Does this mean my truststore should (1) ONLY include Sub CA1 and Sub CA2, or (2) should it include Root CA, Sub CA1, and Sub CA2?
I don't know what is the proper way to represent this trust chain in a truststore. In the future I would also like to add a Sub CA4 (also signed/issued by the Root CA), but add that to a Certificate Revocation List (CRL) for testing purposes.
Ahead of time, thank you for any help concerning this. It's greatly appreciated.
Computer[] labComputers = new Computer[10];
with
public class Computer {
...
void toString(){
// print computer specs
}
}
public class Notebook extends Computer{
...
void toString(){
// print computer specs + laptop color
}
}
each subscripted variable labComputers[i] can reference either a Computer object or a Notebook object because Notebook is a subclass of Computer. For the method call labComputers[i].toString(), polymorphism ensures that the correct toString method is called.
I wonder what if we do
Notebook[] labComputers = new Notebook[10];
what kind or error would I get if I reference with Computer object and a Notebook object
Hello,
I have a xml where I got some empty complex elements and I need to access the attribute values of this element.
<test>
<a>
<abc-metadata name="testData" value="This is a test"/>
</a>
</test>
I want to get hold of the 'testData' and 'This is a test' values.
I do read the document and I tried accessing it document.getElementsByTagName . I am sure there is some way to access attributes of element tags but somehow it throws me nullpointer exception.
Thanks in advance
Hello. I have dynamic tree (moreover nodes can have children). Every node has some action. When I right click on some node, it offers me some actions. One action, for example createChildNode creates child node, which in turn creates MyObject2. MyObject2 must be created with assistance of MyOject1, which was created in parent node(that one where I right click for actions ).
How to get that object from selected node? That objects in nodes are putted to lookups.singleton(MyObjectX)
How can we use AtomicInteger for limited sequence generation say the sequence number has to be between 1 to 60. Once the sequece reaches 60 it has to start again from 1. I wrote this code though not quite sure wether this is thread safe or not?
public int getNextValue()
{
int v;
do
{
v = val.get();
if ( v == 60)
{
val.set(1);
}
}
while (!val.compareAndSet(v , v + 1));
return v + 1;
}
hello,
I'm writing a client server application, but I don't receive the same bytes at the client side when they are sent from the server side.
At the server side I used .write(bytes[]) method. At the client side, I used .readFully(byte[]) method.
Do you have any idea ?
I need some help defining the following object hierarchy/ database relationship in Hibernate
From the object sense – Agent is inherited from Person and Agency is inherited from Organization. they are inherited from Party which can have multiple Addresses associated with it
The database consists of
Agent
- ID
- Name
-PartyID (references Party.ID)
Agency
-ID
-Name
-PartyID (references Party.ID)
Address
-AddrID
-PartyID (references Party.ID)
-Street
Party.
-PartyID