MongoDB check insertion

I controll data inserted or not inserted in mysql as follows public boolean addUser(User user) throws Exception { boolean isRegister=false; Connection conn=null; PreparedStatement ps=null; ResultSet rs=null; try{ String sql="insert into users(usernam

PostgreSQL cross-analysis error

I have this Postgres query: SELECT i.nombre_inspectoria::varchar, p.nombre_pase::varchar, count(a.idatraso)::int from atrasos a inner join inspectorias i on i.idinspectoria = a.idinspectoriafk inner join tipo_pase p on p.idtipo_pase = a.idtipo_pasefk

Java thread dies without notification

I was testing the concurrency with a HashMap (for academic purposes). My goal was to throw some kind of exception related to modifying the structure of the map from multiple threads. It ended up that the threads that have the task to put stuff in my

the label does not appear in Java Gui

i am new in java so i am sorry if this question is easy.I am have issues with using layer. public class LoginPage extends JFrame { private JButton loginBtn = new JButton("Login"); private JLabel nameLbl = new JLabel("UserName: "); publ

Problem printing a table in a JTextArea

The goal of this project is to create four classes: a Student class, a GradStudent class, a Manager class, and a GUI class. Within the GUI there are two radio buttons: one for Student and one for GradStudent. Depending on which one is selected, the M

What is the result of these type conversions and why?

I have some problems understanding what are the types after each System.out.println(); line in this Java code. Right now I am getting errors at line 4 and the rest of the code does not run, can determine what is the problem? Can somebody explain to m

XmlBeans - XSD validation against a type, not an element

I need to validate the following XML against a (complex) type declared in the following XSD, using XmlBeans. My XSD: <xs:schema targetNamespace="" attributeFormDefault="unqualified&quo

Caching the result of a method in Java

I have this method that loads a lot of data from the database private List<Something> loadFromDb() { //some loading which can take a lot of time } I am looking for a simple way to cache the results for some fixed time (2 minutes for example). I do n

Java does not convert from Latin to utf8 correctly

I select data from mysql, the database is not in utf8 (the unicode character is save as latin, for example the unicode string Đỗ Tiến(correct form) is save as Äá»- Tiến). If I use PHP to echo to html, I just set <meta http-equiv="Content-Type&qu

Button background color when using Windows LAF?

I have a Java application which uses the native LAF like so: UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); This is working great, however, I am trying to make a button have a red background, but ends up like this: As you can se

Java error: Should be declared in a named file

I'm fairly new to Java and trying to figure out how to solve the following error: Error reads class Calculator is public, should be declared in a file named public class Calculator So my thought was that t

Patterns do not match regular expressions

I am trying to create a SOA Service in eclipse. And there is one field in which I have to insert Admin Name. So whenever I am entering this as an Admin Name and I am getting this error- Invalid Name. The name [Adcommerce, pubcommerceHelloWorldService

java.lang.IllegalArgumentException: the observer is null

A user of one of my apps reported this error. I'm confused as to what it means an how to fix it. After a bit of googling...still no luck. Anyone seen this before or know how to fix it? java.lang.IllegalArgumentException: The observer is null. at andr

How to create base64Binary data?

What is base64Binary and how can I create base64Binary from a given byte array in Java?Try commons-codec with public static byte[] encodeBase64(byte[] binaryData).

Using graphics from an anonymous class

This is a part of my code which does some sort of animation; however, there seems to be something wrong: Whenever I try to use the passed 'g' from inside the anonymous class to draw anything, it does nothing, yet when I used it outside the anonymous

Java: Comparator and Treeset to remove duplicates

i have a java class like this public class A { private String field1; private String field2; // getters, setters but no equals and hashcode } and a list of objects of this class, i want to remove from this list all the duplicates elements that has th

How to delete a row from the cell table

At first I used the Grid. After creating a new version of the GWT, I want to replace the Grid on the CellTable.Check out the javadoc for details. My example is like the one you'll find there (just a little extended): public void onModuleLoad() { fina

how can I cast string [] in array?

Possible Duplicate: How to create ArrayList (ArrayList<T>) from array (T[]) in Java I have: String[] time = {"22:22:22","22:22:23"}; Array asd = null; How can I put something like asd=time ?I assume that what you actually need is

Get FileSize before InputStream

I want to create a progressBar for an FTP download. The server where I am downloading the file has all of its directories and files hidden. I want to display the progress of the download. Is there any way I can get the file size? Here is my current c

toss a list to a collection

i have some pb. I want to cast a List to Collection in java Collection<T> collection = new Collection<T>(mylList); but i have this error Can not instantiate the type CollectionList<T> already implements Collection<T> - why would yo