Report this

What is the reason for this report?

Why can't I select my table with Spring Boot?

Posted on November 17, 2017

I’m working in an API that access the database to return a String based on an input. I’m using Spring Boot with JDBC to connect a MySQL server at localhost.

I’ve already tested the app in several different systems and it works fine, but when I test it at my droplet the query returns nothing.

I am certain that it connects and there the database is populated. If I use the same query at the mysql terminal it returns the data.

The app returns java.lang.ArrayIndexOutOfBoundsException: 2553 exception when it tries to select the table and prints

 MySQL data: []

2017-11-16 14:06:56.321  INFO 21565 --- [       Thread-4] ationConfigEmbeddedWebApplicationContext : Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@6e5e91e4: startup date [Thu Nov 16 14:06:09 UTC 2017]; root of context hierarchy
2017-11-16 14:06:56.342  INFO 21565 --- [       Thread-4] o.s.j.e.a.AnnotationMBeanExporter        : Unregistering JMX-exposed beans on shutdown
2017-11-16 14:06:56.348  INFO 21565 --- [       Thread-4] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2017-11-16 14:06:56.351  INFO 21565 --- [       Thread-4] org.hibernate.tool.hbm2ddl.SchemaExport  : HHH000227: Running hbm2ddl schema export
2017-11-16 14:06:56.363  INFO 21565 --- [       Thread-4] org.hibernate.tool.hbm2ddl.SchemaExport  : HHH000230: Schema export complete


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hello ,

Based on the information provided, it’s difficult to determine the exact cause of the issue. However, there are a few things that you can check to troubleshoot the problem:

  1. Verify that your MySQL server is running and accessible from your droplet. You can try connecting to your MySQL server from the droplet using the mysql client or a tool like MySQL Workbench.

  2. Check that your database name, table name, and column names are spelled correctly and match the names in your query.

  3. Verify that the user you are connecting to the MySQL server with has the necessary permissions to access the database and table you are querying.

  4. Ensure that the data you are querying is in the correct format for the JDBC driver. For example, if you are querying a date column, ensure that the date is formatted correctly.

  5. Check your application logs for any additional information or error messages that may provide more insight into the problem.

Also, the exception message you provided, java.lang.ArrayIndexOutOfBoundsException, indicates that there is an issue with the size of an array in your code. You should investigate the code that is throwing this exception and ensure that it is handling arrays correctly

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.