Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Database Querying, Packet Size Limitations

  1. #1
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,619
    Thanks
    25
    Thanked 322 Times in 300 Posts

    Default Database Querying, Packet Size Limitations

    So I have an applet that reads an online database, which is quite large.

    When attempting to create the connection to the database, I get the following error:
    com.mysql.jdbc.PacketTooBigException: Packet for query is too large (3158578 > 1048576). You can change this value on the server by setting the max_allowed_packet' variable.
    To my current knowledge, I am unable to change the max_allowed_packet variable, since I believe it is controlled by my host (still checking on this).

    So, clearly the problem is with the size of the connection being too large. Is it possible for me to connect to my database in pieces, instead of the whole thing all at once? Maybe something like bypassing the connection to the whole database and just connecting to a specific table of the database.

    If this isn't possible, I've heard rumors that one could use php or some other scripting language to do a database query and then send the data into a java applet. Is this sort of thing possible and, if it is, does anyone have any documentation I could read or suggestions to give?

    Thanks in advance for any help.
    NOTE TO NEW PEOPLE LOOKING FOR HELP ON FORUM:

    When asking for help, please follow these guidelines to receive better and more prompt help:
    1. Put your code in Java Tags. To do this, put [highlight=java] before your code and [/highlight] after your code.
    2. Give full details of errors and provide us with as much information about the situation as possible.
    3. Give us an example of what the output should look like when done correctly.

    Join the Airline Management Simulation Game to manage your own airline against other users in a virtual recreation of the United States Airline Industry. For more details, visit: http://airlinegame.orgfree.com/


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,262
    Thanks
    176
    Thanked 821 Times in 764 Posts
    Blog Entries
    5

    Default Re: Database Querying, Packet Size Limitations

    Try calling 'set global max_allowed_packet = 500 * 1024 * 1024' from the mysql command line (or whatever you wish your max to be). I've had this problem with MySQL in the past and was able to do this through the command line with success (you could do this on your machine be running the mysql command line tool and specify the appropriate host) - never tried it directly through JDBC but it might be worth trying (the user you login as needs to have permissions to change this global). If the large amount of data is from a single table column you are probably stuck with this option. Otherwise you might be able to piece up the query (say by looping over a limit clause) into subqueries which together get all the data.

    You could have a script to do the query for you, but I don't see it as solving your initial problem.

Similar Threads

  1. How to set the format of a udp packet ?
    By Mezzo in forum Java Networking
    Replies: 0
    Last Post: January 19th, 2011, 05:43 PM
  2. HTTPS packet Capturing
    By zeerussia in forum Java Networking
    Replies: 0
    Last Post: November 10th, 2010, 12:58 AM
  3. Limit File Size or Request Size
    By tarek.mostafa in forum Java Servlet
    Replies: 3
    Last Post: June 12th, 2010, 04:28 PM
  4. Limit File Size or Request Size
    By tarek.mostafa in forum JavaServer Pages: JSP & JSTL
    Replies: 3
    Last Post: June 11th, 2010, 07:21 AM
  5. Replies: 6
    Last Post: October 23rd, 2009, 03:53 AM