<?xml version="1.0" encoding="UTF-8" ?>

<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
    <title>Posteet: haduart</title> 
    <link>http://www.posteet.com/</link> 
    <description>Recent posteets posted to Posteet</description>
    <ttl>60</ttl>

    
    <item>
        <title>Saving a Serialized class into a MySQL Database.</title>
        <link>http://www.posteet.com/view/703</link>
        <description>
        <![CDATA[<pre>/**
	  * Actualitza l'objecte serialitzat (scorm_structure) de 
	  * l'usuari amb l'identificador indicat.
	  * 
	  * Nota! Fa un update, per tant ha d'existir l'usuari!
	  * 
	  * @param courseStudentName : El nom de la taula en que ho guardem.
	  * @param studentId : L'identificador de l'usuari.(int Type) 
	  * @param object : Retornarà l'UserObjective, caldrà fer un cast.
	  * @return int Type: Retornarà l'identificador del resultset.
	  * @throws Exception : Llança una excepció si hi ha un error.
	  */
	private int writeJavaObject(
			final String courseStudentName,
			final int studentId,
			final Object object) 
	 throws Exception {		
		String sqlUpdateScormStructure =
			&quot;UPDATE &quot; + courseStudentName
			+ &quot; set scorm_structure = ? WHERE student_id = ?&quot;;
                /** We already have
                  * private Connection conn = DriverManager.getConnection(url, userName, password);
                  */
		PreparedStatement pstmt =
			conn.prepareStatement(sqlUpdateScormStructure);
		
		ByteArrayOutputStream baos = new ByteArrayOutputStream();
		ObjectOutputStream oout = new ObjectOutputStream(baos);
		oout.writeObject(object); //serializing
		    
		// set input parameters
		pstmt.setBytes(1, baos.toByteArray());		    
		pstmt.setInt(2, studentId);
		pstmt.executeUpdate();

		// get the generated key for the id
		ResultSet rs = pstmt.getGeneratedKeys();
		int id = -1;
		if (rs.next()) {
			id = rs.getInt(1);
		}
		
		rs.close();
		pstmt.close();
		return id;
	}</pre> <a href="http://www.posteet.com/tags/Blob">[Blob]</a>  <a href="http://www.posteet.com/tags/Java">[Java]</a>  <a href="http://www.posteet.com/tags/MySQL">[MySQL]</a> ]]>        </description>
        <dc:creator>haduart</dc:creator>
        <pubDate>Tue, 29 Jan 2008 13:35:10 +0000</pubDate>

            <category>Blob</category>
            <category>Java</category>
            <category>MySQL</category>
    
    </item>

  
    <item>
        <title>Loading a dinamic Library</title>
        <link>http://www.posteet.com/view/699</link>
        <description>
        <![CDATA[<pre>/**
* In the D:/LoadLibrary we must have .class and the same interface (TestString) with the same pacakge as the 
* main program. 
*/
URL urlToJar = new URL(&quot;file://D:/LoadLibrary/&quot;);
URLClassLoader cl = new URLClassLoader(new URL[] { urlToJar });
		
System.out.println(&quot;loading...&quot;);
Class c2 = cl.loadClass(&quot;TestHelloWorld&quot;);
System.out.println(&quot;loaded!&quot;);
Object nouObject = c2.newInstance();

TestString ts = (TestString) cons.newInstance(args);
/**
* Now we can use the &quot;ts&quot; object as a normal TestString interface. No matter which is the implementation that is begin it.
*/
System.out.println(&quot;S1: &quot; + ts.printS1());
System.out.println(&quot;S2: &quot; + ts.printS2());</pre> <a href="http://www.posteet.com/tags/Dinamic">[Dinamic]</a>  <a href="http://www.posteet.com/tags/Java">[Java]</a>  <a href="http://www.posteet.com/tags/Library">[Library]</a> ]]>        </description>
        <dc:creator>haduart</dc:creator>
        <pubDate>Mon, 28 Jan 2008 16:38:34 +0000</pubDate>

            <category>Dinamic</category>
            <category>Java</category>
            <category>Library</category>
    
    </item>


</channel>
</rss>
