i would need to know the past 7 days record. i want to wrote a query for that in where condition. i have very basic knowledge in sqlite. Please help me for this query.
Guys,
I"m trying to use Tyburn to do some BDD with JBehave and I've got a question about what Tyburn can do. Can Tyburn simulate Menu selections? Like Ive I want to say something like
@Then("when I select 'Start' from the Recording Menu)
selectMenu(Recording)
selectMenuItem(Start)
Is there a way to make this happen?
Thanks,
Joe
I'm using Hibernate3.2+Websphere6.0+struts1.3..
After deploying ,application works fine.
After some idle time ,i will get this type of error repeatedly,am not able to login at all.
Im not using any connection pooling. i feel after idle time its not able to connect to the database again..if i restart the server everything works fine for some time...after that same story.. please help me out
A colleague of mine sets reference to null in finally blocks. I think this is nonsense.
public Something getSomething() {
JDBCConnection jdbc=null;
try {
jdbc=JDBCManager.getConnection(JDBCTypes.MYSQL);
}
finally {
JDBCManager.free(jdbc);
jdbc=null; // <-- Useful or not?
}
}
What do you think of it?
I am having a form built up in netbeans and want to add or remove a component with an actionperformed event of a button or a combobox is it possible?
if yes, how?
Hi there,
I'm trying to load a custom font as follows:
private Paint customFont18;
customFont18 = new Paint();
customFont18.setTextSize(18);
Typeface fontFace = Typeface.createFromAsset(getAssets(), "FONT.TTF");
customFont18.setTypeface(fontFace);
The getAssets fails, thows this:
-The method getAssets() is undefined for the type MyClass
-assetManager cannot be resolved to a variable
What is my problem? I've seen several examples like this but none works in my case.
Thanks in advance.
When updating an employee with id = 1 for example, what is the best way to delete all previous records in the table certificate for this employee_id and insert the new ones?.
create table EMPLOYEE (
id INT NOT NULL auto_increment,
first_name VARCHAR(20) default NULL,
last_name VARCHAR(20) default NULL,
salary INT default NULL,
PRIMARY KEY (id)
);
create table CERTIFICATE (
id INT NOT NULL auto_increment,
certificate_name VARCHAR(30) default NULL,
employee_id INT default NULL,
PRIMARY KEY (id)
);
Hibernate mapping
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="Employee" table="EMPLOYEE">
<id name="id" type="int" column="id">
<generator class="sequence">
<param name="sequence">employee_seq</param>
</generator>
</id>
<set name="certificates" lazy="false" cascade="all">
<key column="employee_id" not-null="true"/>
<one-to-many class="Certificate"/>
</set>
<property name="firstName" column="first_name"/>
<property name="lastName" column="last_name"/>
<property name="salary" column="salary"/>
</class>
<class name="Certificate" table="CERTIFICATE">
<id name="id" type="int" column="id">
<param name="sequence">certificate_seq</param>
</id>
<property name="employee_id" column="employee_id" insert="false" update="false"/>
<property name="name" column="certificate_name"/>
</class>
</hibernate-mapping>
I'm building an application where space is at a premium. I'd really like to use JAXB's unmarshalling capabilities, but including the whole library is out of the question. Has anyone paired it down so that only the bits needed for unmarshalling are included?
Basically I'm trying to make a little app for watching offline content. So there's a moment where the user selects to download the contents (and the app should download about 300 small files and images).
I'd like to show the user how does the process go if he enters the proper activity. Showing a list of all the files, telling what has been already downloaded, in progress or waiting for download.
My problem is that I really don't know what approach to take for achieve this. Since the download should last until finished I imagine the solution is an Service, but whats best? an IntentService, a Bound Service or an Standard Service calling a startService() for each download? And how can I keep my objects updated for displaying them later? should I use a database or objects in memory?
Thanks
I am trying to connect to a Sharepoint 2007 using HttpClient 4. The Authentication scheme is NTLM and i wrote an implementation based on this (http://hc.apache.org/httpcomponents-client-ga/ntlm.html).
When i try to connect supplying NTCredentials (username,password,host & domain), i get a 500 error saying "The requested function is not supported".
I am trying to understand this error. Does anyone know what this error is? and Why is this occuring?
Thanks
Problem
One friend suggested an interesting problem. Given the following code:
public class OuterClass {
private String message = "Hello World";
private class InnerClass {
private String getMessage() {
return message;
}
}
}
From an external class, how may I print the message variable content? Of course, changing the accessibility of methods or fields is not allowed.
(the source here, but it is a french blog)
Solution
The code to solve this problem is the following:
try {
Method m = OuterClass.class.getDeclaredMethod("access$000", OuterClass.class);
OuterClass outerClass = new OuterClass();
System.out.println(m.invoke(outerClass, outerClass));
} catch (Exception e) {
e.printStackTrace();
}
Note that the access$000 method name is not really standard (even if this format is the one that is strongly recommanded), and some JVM will name this method access$0. Thus, a better solution is to check for synthetic methods:
Method method = null;
int i = 0;
while ((method == null) && (i < OuterClass.class.getDeclaredMethods().length)) {
if (OuterClass.class.getDeclaredMethods()[i].isSynthetic()) {
method = OuterClass.class.getDeclaredMethods()[i];
}
i++;
}
if (method != null) {
try {
System.out.println(method.invoke(null, new OuterClass()));
} catch (Exception e) {
e.printStackTrace();
}
}
So the interesting point in this problem is to highlight the use of synthetic methods. With these methods, I can access a private field as it was done in the solution. Of course, I need to use reflection, and I think that the use of this kind of thing can be quite dangerous...
Question
What is the interest - for me, as a developer - of a synthetic method? What can be a good situation where using the synthetic can be useful?
Hi,
I'm testing the CRUD operations of my DAOs in JUnit tests.
When i execute the single test, Hibernate always resets the schema and populates the DB in a known state. But when i execute multiple tests in a row, Hibernate resets the schema once, and then the data is accumulated during the execution of the tests.
This is an unexpected behavior, so I'd like to add in the @Before method of the tests a function that explicitly resets the schema to avoid the pesistence of side data created by previous tests during the execution chain.
Any tips?
Thanks
Using axis1 it is possible to log incoming/outgoing soap messages by adding logging on HTTPSender in log4j.properties. After migrating to axis2 (version 1.4.1) I have a hard time figuring out how to accomplish the same kind of logging. I have tried to add logging on the axis2 package and org.apache.commons.httpclient but no logging is provided.
Any ideas?
TIA
I am in the midst of changing my JPA code around to make use of threads. I have a separate entity manager and transaction for each thread.
What I used to have (for the single threaded environment) was code like:
// get object from the entity manager
X x = getObjectX(jpaQuery);
if(x == null)
{
x = new X();
x.setVariable(foo);
entityManager.persist(x);
}
With that code in the multi threaded environment I am getting duplicate keys since, I assume, getObjectX returns null for a thread, then that thread is swapped out, the next thread calls getObjextX, also getting null, and then both threads will create and persist a new X().
Short of adding in synchronization, is there an atomic way to get/save-if-doesn't-exist a value with JPA or should I rethink my approach
EDIT:
I am using the latest Eclipselink and MySql 5.1
At the end of the README.txt file which is located in the example directory under solr, I find this line:
NOTE: This Solr example server references SolrCell jars outside of the server
directory with statements in the solrconfig.xml. If you make a copy of
this example server and wish to use the ExtractingRequestHandler (SolrCell),
you will need to copy the required jars into solr/lib or update the paths to
the jars in your solrconfig.xml
What does this mean?
Do I have to make some adjustment before uploading solr to my server?
Also, if you know, what is Solr-nightly:s difference to regular solr?
The tutorial states "solr-nightly.zip" but on their download section I cant find it.
hello i am a student and i am doing my senior project it is about developing an application in j2me for scanning a barcode and extract the number of the barcode in a message to be send.
please i search the net but i cant found something usefull i am new at j2me if someone could help me with sourch code and how to create it i will be very thankfull my email is [email protected]
thanks in advanced
What would happen if an exception is thrown during the execution of finalize()?
Is the stack unwind like normally? Does it continue finalize() and ignore the exception? Does it stop finalize() and continue GC the object? Or something else?
I'm not looking for guidelines of using finalize() there are plently of pages explaining that.
I jsut learned that
A class may be declared with the
modifier public, in which case that
class is visible to all classes
everywhere. If a class has no modifier
(the default, also known as
package-private), it is visible only
within its own package.
This is a clear statement. But this information interfere with my understanding of importing of packages (which easily can be wrong). I thought that importing a package I make classes from the imported package visible to the importing class.
So, how does it work? Are public classes visible to all classes everywhere under condition that the package containing the public class is imported? Or there is not such a condition? What about the package-private classes? They are invisible no mater if the containing package was imported or not?
ADDED:
It seems to me that I got 2 answers which are marked as good (up-voted) and which contradict eachother.
I'm working on a Serpinski triangle program that asks the user for the levels of triangles to draw. In the interests of idiot-proofing my program, I put this in:
Scanner input= new Scanner(System.in);
System.out.println(msg);
try {
level= input.nextInt();
} catch (Exception e) {
System.out.print(warning);
//restart main method
}
Is it possible, if the user punches in a letter or symbol, to restart the main method after the exception has been caught?
I have this weird issue,when I use
> File FileToRead = new File("\\\\MYSERVER\\MYFOLDER\\MYFOLDER\\MYPICTURE.JPG");
to read a file over a network,all I get is a null pointer exception.Normally a local path works with this,but when on a network path,I just couldn't manage to get it to work.Any ideas?
PS:oh and my network connection seems to work,no issues when accessing data in windows explorer...
More of the code:
File FileToRead = new File("file://DOKSERVICE/Somefolder/ProductImage/01001.JPG");
// File FileToRead = new File("c:\\dog.jpg"); local test
BufferedImage image = ImageIO.read(FileToRead);
BufferedImage resizedimage = new BufferedImage(260, 260,BufferedImage.TYPE_INT_RGB );
Graphics2D g = resizedimage.createGraphics();
g.drawImage(image, 0, 0, 260, 260, null);
g.dispose();
picture.setIcon(new ImageIcon(image));
How can I add the domain root path to the Oracle WebLogic 11g (10.3.2) AdminServer classpath? (Note that I am not running the Node Manager.) Which WebLogic startup script sets environment variable WEBLOGIC_CLASSPATH? Is this the variable to which I should add the domain root?
I have a JUnit 4 test suite with BeforeClass and AfterClass methods that make a setup/teardown for the following test classes.
What I need is to run the test classes also by them selves, but for that I need a setup/teardown scenario (BeforeClass and AfterClass or something like that) for each test class. The thing is that when I run the suite I do not want to execute the setup/teardown before and after each test class, I only want to execute the setup/teardown from the test suite (once).
Is it possible ? Thanks in advance.
Hi gents,
We all know that in order to invoke Object.wait() , this call must be placed in synchronized block,otherwise,IllegalMonitorStateException is thrown.But what's the reason for making this restriction?I know that wait() releases the monitor, but why do we need to explicitly acquire the monitor by making particular block synchronized and then release the monitor by calling wait() ?
What is the potential damage if it was possible to invoke wait() outside synch block, retaining it's semantics - suspending the caller thread ?
Thanks in advance