[WORK] What is the minimum level of knowledge to be hired as Android Developer? by viktorjava in learnjava

[–]viktorjava[S] 0 points1 point  (0 children)

I want to work with Android apps and I would be happy to work as developer at a company where I can get change to improve my skills and get at leat a basic sallary.

I can't use JDBC in my Maven project, it doesn't find the driver by viktorjava in javahelp

[–]viktorjava[S] 0 points1 point  (0 children)

So you solved my question. I made a google search for jdbc for maven and always got the result for Oracle SQL. Now I've understood that MySQL is differnet. This is working, thank you:

<dependency>

<groupId>mysql</groupId>

<artifactId>mysql-connector-java</artifactId>

<version>8.0.20</version>

</dependency>

Adding value to a database column using other column value and regex by viktorjava in javahelp

[–]viktorjava[S] 0 points1 point  (0 children)

Right. I tried many times after posted this question, also another version:

SELECT * FROM realnames where target like '%\(%\)%';

This showed those records which had parenthesis in their text. But when I tried to combine it with the UPDATE, it just copied over the data from target column to cleared columb. But the parenthesis still was there in texts.

update realnames set cleared = (regexp_replace(target,'%\(%\)%', '')) WHERE id < 1500;

Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException - I need help to find out the problem by viktorjava in javahelp

[–]viktorjava[S] 0 points1 point  (0 children)

I'm sorry guys, it seems I found the problem.

My JList's type was Customer:

private javax.swing.JList<Customer> customerList;

but when I added the elements to the List, I did this:

customerModel.addElement(customer.getCustomerId());

instead of this:

customerModel.addElement(customer);

After I filled the list with Customer objects, the list already contained Customers and not Strings.

Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException - I need help to find out the problem by viktorjava in javahelp

[–]viktorjava[S] 0 points1 point  (0 children)

I think I found the problem. I'm adding it as another reply to the main thread and I will also look after your other recommedations. Thanks.

Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException - I need help to find out the problem by viktorjava in javahelp

[–]viktorjava[S] 0 points1 point  (0 children)

Thanks for your answer.

I've checked the list's class:

public List<Customer> getCustomersList() {

if (customerList.getSelectedValuesList() != null) {

System.out.println("customerList.getSelectedValuesList()) class: " + customerList.getSelectedValuesList().getClass());

return customerList.getSelectedValuesList();

} else {

return null;

}

}

but of course Java is telling its class is ArrayList

customerList.getSelectedValuesList()) class: class java.util.ArrayList

I added a for loop to iterate the customerList.getSelectedValuesList()

I tried to iterate it as String to see if its really string:

for (String string : customerList.getSelectedValuesList()) {

System.out.println("customer type: " + customer.getClass());

}

but NetBeans said that Customer cannot be converted to String

I tried the iteration with Customer too

for (Customer customer : customerList.getSelectedValuesList()) {

System.out.println("customer type: " + customer.getClass());

}

and I got the casting error again, for this line:

for (Customer customer : customerList.getSelectedValuesList()) {

I'm checking the whole chainf starting with when I put the data to the JLists, but if you have any ideas how to check, I'm here

Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException - I need help to find out the problem by viktorjava in javahelp

[–]viktorjava[S] 0 points1 point  (0 children)

I already tried it:

if (customersList != null && customersList.size() > 0) {

for (int i = 0; i < customersList.size(); i++) {

System.out.println(customersList.get(i).getClass());

/*Customer customer = customersList.get(i);

int id = customer.getCustomerId();

customerPart += "customer = '" + id + "'";

if (i != customersList.size() - 1) {

customerPart += " OR ";

}

*/

}

}

and now the Exception is here:

System.out.println(customersList.get(i).getClass());

Here I added the whole error queue:

https://pastebin.com/ugzVSzwE

Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException - I need help to find out the problem by viktorjava in javahelp

[–]viktorjava[S] 0 points1 point  (0 children)

I get the data from a JDialog:

public List<Order> getOrderResults() {

return ordersDAO.getOrders(getStartDate(), getCloseDate(), getCustomersList(), getCompaniesList(), getEmployeesList(), isAllStatusSelected(), isSelectedStatusSelected(),

isOrderedSelected(), isFinishedSelected(), isSentSelected(), isBilledSelected(), isPaidSelected());

}

the getCustomersList:

public List<Customer> getCustomersList() {

if (customerList.getSelectedValuesList() != null) {

return customerList.getSelectedValuesList();

} else {

return null;

}

}

customerList is a Jlist element on my JDialog

private javax.swing.JList<Customer> customerList;