Saturday, June 23, 2007

J2ME Custom Item

Recently i came to know a tremendous thing of J2ME. I worked little on J2ME. I wanted to make a scrollable textbox which can be appended to a form. So i searched then net and came to know a great thing named Custom Item. This is such an item which you build by yourself and you can add this item to a form. This items have their own paint() method. So you can customize it's look and feel too. The limitation is you can only use it in MIDP 2.0 profiled devices. But it's nice to make one of your own :D. I think J2ME polish uses custom items to change the look and feel of their items.

 

This links are just great. You can see if u want to learn Custom Item

http://www.ibm.com/developerworks/wireless/library/wi-developui/

http://developers.sun.com/mobility/midp/ttips/customitem/

http://www.google.com/search?hl=en&q=j2me+custom+item&btnG=Google+Search

http://safari.ciscopress.com/9780321463425/ch10

I was trying to connect to an ms access database using JDBC. Am a bad learner so it took a lot of time for me to finish it. After googling i found some code to work with java and access. Some of the code is shown below

 

import java.sql.*;

 

try {
        System.out.println("Begining conn");
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            String filename = "c:/nsu.mdb";
            String database = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=";
            database+= filename.trim() + ";PWD=test}"; // add on to the end
            // now we can get the connection from the DriverManager
            Connection con = DriverManager.getConnection( database ,"shimul","test"); 
         Statement stmt = con.createStatement();
        System.out.println("Conn done succesfully");
        stmt.execute("select * from t");
        
         ResultSet rs = stmt.getResultSet(); // get any Resultt that came from our query
         if (rs != null)
          while ( rs.next() ){
              System.out.println("Name: " + rs.getString("a") + " ID: "+rs.getString("b"));
          }
          stmt.close();
          con.close();
     }
     catch (Exception err) {
        System.out.println("ERROR: " + err);
     }

 

But i got some error like

java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Record(s) cannot be read; no read permission on 't'.

 

I tried googling but found few result, after a lot of googling i came to know some solutions which was near to this then finally got the solution

 

First open the file in access, give password, then From Tool->Security-> User and Group Permissions -> then select the table and for the admin account give it all kind of access. This will solve your access problems.

 

You can use the above code by changing the statements for insertion deletion update etc. You might have to change the stmt.execute accordingly. Jdbc driver may be required which can be downloaded from sun.java.com . I dont know but mine was already there, new versions of JDK have built in jdbc:odbc support.

Tuesday, June 19, 2007

 this is a sample blog entry from my desktop using the windows live writer. Which helps the users to post blog from PC. You can get the software from here. From here you can post to different blogs. Enjoy :D

Saturday, June 16, 2007

Got a job



Recently got a job, i thought previously that it would be great to get a job, but after getting one i found that it's not that enjoyable. Though getting none is more frustrating than this. But after getting 1 i thought that i just robbed someone else's job, who might need the job more, who is more eligible for the job. I'm not sure about anything. Let's see what happens. One thing i came to know that we have to dream hard, which i can't.


Jaukga pray for me brothers :D