Updates from November, 2012 Toggle Comment Threads | Keyboard Shortcuts

  • CG 7:21 pm on November 13, 2012 Permalink | Reply
    Tags: , , java heap space   

    Resolving Java Heap Space Error 

    My previous code processed two tables with thousands of rows and had problem with Java Heap Space like shown below:

     

     

    To overcome this out of memory problem, we should increase the heap size by typing this on command prompt:

     

    And now it works:

     

    More useful links about Java heap space:

    1. http://javarevisited.blogspot.com/2011/09/javalangoutofmemoryerror-permgen-space.html
    2. http://javarevisited.blogspot.com/2011/05/java-heap-space-memory-size-jvm.html
    3. http://stackoverflow.com/questions/1565388/increase-heap-size-in-java
    4. http://javahowto.blogspot.com/2006/06/6-common-errors-in-setting-java-heap.html
    5. http://viralpatel.net/blogs/jvm-java-increase-heap-size-setting-heap-size-jvm-heap/
    6. http://www.devx.com/tips/Tip/5578
    7. http://publib.boulder.ibm.com/infocenter/wmbhelp/v6r1m0/index.jsp?topic=%2Fcom.ibm.etools.mft.doc%2Fac55070_.htm
    8. http://www.ehow.com/how_5347474_set-java-heap-space.html
    Advertisements
     
  • CG 6:11 pm on November 7, 2012 Permalink | Reply
    Tags: ,   

    Hello World – Python 

    I’m learning Python 😀

    This is the version of Python I’m using:

    And then start using vi to type the code:

    The listing of the code:

    And run the code:

    Ok that’s it for now, I don’t know yet what is so good about Python compared to other languages I’m familiar with (C/C++, Java, Perl). Will post more about this as soon as I learn more about Python.

     
  • CG 7:17 pm on November 6, 2012 Permalink | Reply
    Tags: inserting variable into table, , , PreparedStatement, ResultSet   

    Inserting into MySQL Table 

    Here’s how to get result from a table using ResultSet and use it as variables to be inserted to another table using PreparedStatement

    
    import java.sql.*;
    import java.sql.DriverManager;
    import java.sql.Connection;
    import com.mysql.jdbc.Driver;
    import java.net.*;
    import java.io.*;
    public class CountUser{
    public static void main(String args[]) {
    try{
    Class.forName("com.mysql.jdbc.Driver");
    // Connection connection = DriverManager.getConnection("jdbc:mysql://167.205.24.50/table","root","");
    Connection connection = DriverManager.getConnection("jdbc:mysql://localhost/table","root","");
    Statement st1 = connection.createStatement();
    Statement st2 = connection.createStatement();
    
    ResultSet rs1 = st1.executeQuery("SELECT * FROM user");
    
    while (rs1.next()) {
    java.sql.Date date = rs1.getDate(5);
    String strDate = date.toString();
    
    PreparedStatement ps = connection.prepareStatement("INSERT INTO count_temp (no, date) VALUES (?,?)");
    ps.setInt(1, i);
    ps.setString(2, strDate);
    ps.executeUpdate();
    }
    }
    catch (Exception e){
    System.out.println("Error: " + e);
    }
    }
    }
    
     
c
Compose new post
j
Next post/Next comment
k
Previous post/Previous comment
r
Reply
e
Edit
o
Show/Hide comments
t
Go to top
l
Go to login
h
Show/Hide help
shift + esc
Cancel