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!
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:
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.
Check that your database name, table name, and column names are spelled correctly and match the names in your query.
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.
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.
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
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.