Home Answers Viewqa SQL How to make a connection from javaME with MySQL

 
 


Amirul
How to make a connection from javaME with MySQL
1 Answer(s)      4 years and 4 months ago
Posted in : SQL

View Answers

March 12, 2009 at 4:34 AM


Hi friend,

Code to help in solving the problem :

import java.io.*;
import javax.microedition.midlet.*;
import javax.microedition.rms.*;

public class RecordDataBase extends MIDlet {
static final String DBNAME = "RecordDataBase";

public void startApp(){
RecordStore rs = null;
try{
RecordStore.deleteRecordStore(DBNAME);
} catch(Exception e){}

try{
rs = RecordStore.openRecordStore(DBNAME, true);
byte[] data1 = "First Record".getBytes();
byte[] data2 = "Second Record".getBytes();
byte[] data3 = " Third Record".getBytes();
data3[0] = 0;
data3[data3.length-1] = (byte) -1;
rs.addRecord(data1, 0, data1.length);
rs.addRecord(data2, 0, data2.length);
rs.addRecord(data3, 0, data3.length);
storeData(rs, System.out);
rs.closeRecordStore();
}catch(RecordStoreException e){
System.out.println(e);
}
notifyDestroyed();
}

public void pauseApp(){}

public void destroyApp(boolean unconditional){}

public void storeData(RecordStore rs, PrintStream out){
if(rs == null) return;
StringBuffer hexLine = new StringBuffer();
StringBuffer charLine = new StringBuffer();

try{
int lastID = rs.getNextRecordID();
byte[] data = new byte[100];
int size;

for(int i = 1; i < lastID; ++i){
try{
size = rs.getRecordSize(i);
if(size > data.length){
data = new byte[size * 2];
}
out.println("-------------------------------------");
out.println("Size = " + size);
out.println("-----------------------------------");
rs.getRecord(i, data, 0);
storeRecord(data, size, out, hexLine, charLine, 16);
out.println(" ");
} catch(InvalidRecordIDException e){
continue;
}
}
} catch( RecordStoreException e ){
out.println(e);
}
}

private void storeRecord(byte[] data, int size, PrintStream out, StringBuffer

hexLine, StringBuffer charLine, int maxLen ){
if(size == 0) return;
hexLine.setLength(0);
charLine.setLength(0);
int count = 0;
for(int i = 0; i < size; ++i){
char b = (char) (data[i] & 0xFF);

if(b < 0x10){
hexLine.append('0');
}
hexLine.append(Integer.toHexString(b));
hexLine.append(' ');

if((b >= 32 && b <= 127) ||
Character.isDigit(b) ||
Character.isLowerCase(b) ||
Character.isUpperCase(b)){
charLine.append((char)b);
} else {
charLine.append(' ');
}

if(++count >= maxLen || i == size-1){
while(count++ < maxLen){
hexLine.append(" ");
}
hexLine.append(' ');
hexLine.append(charLine.toString());
out.println( hexLine.toString());
hexLine.setLength(0);
charLine.setLength(0);
count = 0;
}
}
}
}

Thanks









Related Pages:
How to make a connection from javaME with MySQL - SQL
How to make a connection from javaME with MySQL  Hi i`m a final year student from one of university from malaysia, I have a problem about my final... and MySQL. I really hoping someone could help me on my final year project
How to make a connection from javaME with MySQL - SQL
How to make a connection from javaME with MySQL  Hi i`m a final year student from one of university from malaysia, I have a problem about my final... and MySQL. I really hoping someone could help me on my final year project
how to write and read text for javaME
how to write and read text for javaME  Hi. I have tried ur read/write coding but why i didnt get the o/p just like urs. do i have to add anything from the library? i want to type multiple line on text file then, read it from
Connection to Database
I manually make a connection to MySQL database in my web pages? How joomla is connection to MySQL without getting any connection error? For reference, My... is the code how I am connecting to MySQL: I am connection to MySQL database in 2
connection
connection   how to make multiple database connection using jdbc
MySQL Connection String
MySQL Connection String       This section gives you brief description of MySQL connection string. For the connection in mysql, we need some information about database like server
connection with MySQL to java.
connection with MySQL to java.   how to connect MySQL database with jsp
how to make employee i card
how to make employee i card  hello friends can anyone help me.. I... problems with database and jsp connection ... also tell me how to retrive data...("com.mysql.jdbc.Driver").newInstance(); Connection con=DriverManager.getConnection("jdbc:mysql
JDBC Connection Pool
and see how to use Apache DBCP for creating the database connection pool. We... a new connection from the database for each user request is a huge work... of connection in a pool and then get the connection from the pool to process user
how to auto generate number in jsp with the database connection mysql for employee number?
how to auto generate number in jsp with the database connection mysql for employee number?  how to auto generate number in jsp with the database connection mysql for employee number?   <%@page import="java.sql.
how to auto generate number in jsp with the database connection mysql for employee number?
how to auto generate number in jsp with the database connection mysql for employee number?  how to auto generate number in jsp with the database connection mysql for employee number?   <%@page import="java.sql.
jdbc connection
"); Connection con = (Connection) DriverManager.getConnection("jdbc:mysql://127.0.0.1...jdbc connection  How to Submit data????   <%-- view... { Class.forName("com.mysql.jdbc.Driver"); Connection con = (Connection
JSP - MySQL - Connection
JSP - MySQL - Connection  I can't connect mysql using jsp in my... from the server was 1,300,257,595,704 milliseconds ago. The last packet sent... to resolve this problem.I set classpath for the mysql connector jar (/home/aghiltu/apache
how to connect mysql from gui?
how to connect mysql from gui?  i am unable to connet to mysql server from my projet that is gui for mysql...can anyone help me in this...its urgent? i have to connet to mysql from gui..   Hi Friend, Try the following
Database connectivity Hibernate mysql connection.
Database connectivity Hibernate mysql connection.  How to do database connectivity in Hibernate using mysql
how to make paging with function ?
how to make paging with function ?  how to make paging with function ?   //this page is display.php <?php</p> $con=mysql_connect... ""; } echo ""; $query = mysql_query("SELECT COUNT(id) AS numrows FROM login
A JDBC Connection Pooling Concept
; } JDBC Connection Pooling JDBC Connection pooling is similar to any other object pooling. Connection pooling is very useful for any application which uses database database as backend. Database connection is very expensive to create
PHP Mysql Database Connection
The Tutorial illustrate an example from PHP Mysql Database Connection... PHP Mysql Database Connection       PHP Mysql Database Connection is used to build a connection
PHP SQL Connection
; PHP SQL Connection is used to access and return the records from PHP... an example that helps you to understand how to establish the database connection...;; $connection = mysql_connect($host,$user,$password) or die("Could
Enhancement for connection pool in DBAcess.java
(); if(connection1 == null) throw new SQLException("Cannot allocate connection from... ").append(i).append(" from connection pool<p>").toString(); } public static... have try to make some modification to improve current connection pool
connection pooling - JDBC
connection pooling  how to manage connection pooling?   Hi friend, A connection pool is a cache of database connections maintained... commands on a database. It open and maintain a database connection for each user
connection with database - JSP-Servlet
connection with database  I tried the DSN and connection... { Connection con=null; Class.forName...=stm.executeQuery("select * from subject"); while(res.next
Hibernate- Oracle connection - Hibernate
to make a connection to oracle DB from eclipse. Thanks... and password as scott and tiger. clicked Test connection. I'm getting Ping... could not establish the connection
how to make paging with class and ajax
how to make paging with class and ajax  paging with class and ajax...; function connect(){ $connectect = mysql_connect("localhost","root","") or die(mysql_error()); $selected = mysql_select_db(mydata) or die(mysql
combo box connection
combo box connection  how to provide connection between three combo... box is my subjects.what's the coding to provide the connection between this three...--"); Class.forName("com.mysql.jdbc.Driver"); Connection con
mysql - WebSevices
mysql  hello all, How can I select one row at a time from 1st table and also from 2nd table and write it to a file line by line. If I use a while loop it is selecting all rows from 1st table and this is writing all
socket connection: how to parse data from server?
socket connection: how to parse data from server?  hi, I am a j2me programmer,i want to retrieve some data from server using socket connection,I h'v established the connection through the port and getting the data from the server
connection - SQL
connection  how can i establish connection between netbean_ide6.9 with mysql or oracle  Hi Friend, Please visit the following link: http://www.roseindia.net/jsf/visual-jsf.shtml Hope that it will be helpful
connection
connection  how to connect the our text editor with the Command Prompt? through which method avilable for it? how to use that method
store data from a variable in mysql?
store data from a variable in mysql?  sir last time asked you tell me how to retrieve data from a database mysql and store it in an int variable... of the calculation from an int variable into mysql in a new table of database. how
connection
connection   How to get connected to my database using jsp   Please visit the following links: http://www.roseindia.net/jsp/connectjspwith_mysql.shtml http://www.roseindia.net/jsp/displaydatafrom_database1.shtml http
connection
connection  sir i have created a web page for login form and i have also created the related data base in both ms access and oracle 10g now how to store those values in form to databases can u plz hlp me
connection - JDBC
connection  how to connect server pages to mysql  Hi Friend, To learn how to connect MySql to JSP, please visit the following link: http://www.roseindia.net/jsp/connect-jsp-mysql.shtml Thanks
Connection pooling
Connection pooling  Sir, In my project i want to implement connection pooling with ms-sql server 2005. i wrote the code in JSP like this... <% Connection con=DbCon.getConnection(); Statement stmt
JDBC connection closed.. - Java Beginners
that if you make the database connection and fetch the data and store it in the HashMap and after that you close the connection, now if you fetch the value from...JDBC connection closed..  if the connections r closed..the values
mysql
is the link for the page from where you can understand how to Download and Install MySQL... from mysql database.......   Hi friend, MySQL is open source database...mysql  How can install My sql drivers using a jar File   Hi
View Photo From Db MySql
View Photo From Db MySql  Good Morning Sir, Please help me, I make a small code but i have a error. I want to make viewer photo from database MySql into my project in netbeans. this is my code : try
MySQL How to Topic
database?     How do you migrate from MySQL 4.x to 5.0... password in MySQL    How do I access MySQL from Java...#java   How do I access MySQL from Python? http
How to make phone call from web application
How to make phone call from web application  I'm creating an XHTML... to make call to a specific number when user clicks a particular button. Please suggest on how to do this. I'm new to this. Thanks in advance
how to insert and retrieve an image from mysql using java - Java Beginners
how to insert and retrieve an image from mysql using java  how to insert and retrieve an image from mysql using java?  Hi friend, Code... SQLException { // declare a connection by using Connection interface
PDO MySQL
PDO MySQL: MySQL is one of the most popular open source database, in this current tutorial we will come to know how to connect MySQL with PHP using PDO. Most of the web developers use MySQL with PHP, and most of the examples in our
secure php mysql connection
secure php mysql connection  secure php mysql connection script
iPhone Make Call from App
iPhone Make Call from App  iPhone Make Call Programmatically I have created an application in iPhone that has the functionality to make Call from App. I am just wondering how to make a call programmatically... is there any
Struts2 connection pooling - Struts
Struts2 connection pooling  Dear Friends , How to make connection pooling in "Struts 2
Struts2 connection pooling - Struts
Struts2 connection pooling  Dear Friends , How to make connection pooling in "Struts 2
how to connect mysql with JDBC - JDBC
how to connect mysql with JDBC  I have created three tables... { connection = DriverManager.getConnection("jdbc:mysql://localhost... a table!"); Connection con = null; String url = "jdbc:mysql
How To Retrieve Image From From MySQL Using Java
How To Retrieve Image From From MySQL Using Java In this section we will discuss about how to retrieve image from the MySQL using Java. This example explains you about all the steps that how to retrieve image from MySQL database
how to make enable/disable textbox in while(rs.next)
how to make enable/disable textbox in while(rs.next)  Hi, I'm trying.../disable function,the data are updated correctly. Is my javascript wrong? How do i... department : <br> <% Connection con = null; try
how to make enable/disable textbox in while(rs.next)
how to make enable/disable textbox in while(rs.next)  Hi, I'm trying.../disable function,the data are updated correctly. Is my javascript wrong? How do i... department : <br> <% Connection con = null; try
how to fetch image from mysql using jsp
how to fetch image from mysql using jsp  how to fetch image from mysql using jsp