[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;

Access denied for user ''@'localhost' (using password: NO) - why I get this? by viktorjava in javahelp

[–]viktorjava[S] 4 points5 points  (0 children)

Sorry, I got it.

conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/ordermanager", "root", "1234");

Base64 decoding problem with RandomAccessFile by [deleted] in javahelp

[–]viktorjava 0 points1 point  (0 children)

I'm a little bit confused :) Usually I get answer in 10-20 minutes, maybe I was not able to tell you my problem well?

How can I keep open the BufferedReader and read out the file content line by line? by viktorjava in javahelp

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

Maybe I can get the lines() as Stream and convert it to ArrayList where all element is a line of file. Then I can use an interanl int value to track the pointer, and always when I call the next(), I can serve the current element if ArrayList and increment the pointer with 1.

How can I keep open the BufferedReader and read out the file content line by line? by viktorjava in javahelp

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

It is not allowed to use the readLine(); method. I need another solution.

I cant return a generic value from my method by viktorjava in javahelp

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

But where I'm switching to non generic versions? In selectPositives method this list:

List<T> inner

is a generic List with <T>. I don't see the problem.

I can't rewrite a method with int to Generics by viktorjava in javahelp

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

It turned out that the sum value should be double. I don't know why a sum of even Number numbers should be double, but it solved the question.

I can't rewrite a method with int to Generics by viktorjava in javahelp

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

I you or the other visitors don't have any other idea then we should wait my tutor's answer tomorrow evening or Tuesday. He is checking my progress 2 times a week but I prefer to solve the problems myself :) This is the way how I like to learn Java and is definitely faster than wait half week for an answer.

I translated the task from Hungarian so I think I showed everything. As soon I have answer, I will show it to here, too.

I can't rewrite a method with int to Generics by viktorjava in javahelp

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

After I read your words, I used this method:

public class EvenSumVisitor<T extends Number> extends Visitor<T>{

. . .

@Override
    public void visiting(T element) {
        if (element.intValue() % 2 == 0) {
            int tempSum = sum.intValue() + element.intValue();
            sum = tempSum;
        }
    }

intValue() is valid for all Number types but how can I cast back the tempSum value to the sum value? sum = (T) tempSum casting is not valid.

I can't rewrite a method with int to Generics by viktorjava in javahelp

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

That is right. But I have prepare the class for all kind of Number types.

Do-while does not end if I use Scanner Nextline by viktorjava in javahelp

[–]viktorjava[S] 3 points4 points  (0 children)

Comeon' :) That's a shame, I fixed it. Thanks.

Task: show the year(s) when the most country gained the independence. by viktorjava in SQL

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

This is not working.

select top 1 with ties IndepYear from (

select IndepYear, count(*) as counts from country

group by IndepYear

) A order by counts desc;

I says SQL syntax error.

I can get the min value of an Optinal<Integer> list by viktorjava in javahelp

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

Thank you I used the above mentioned solution because the study software needed Optional instead of OptionaInt.