sqlite怎么与eclipse连接起来呢?
4个回答
展开全部
1、下驱动。
2、放到磁盘里。一般放到JDK的lib下。
3、配置CLASSPATH路径。这里配置的/etc/profile文件。也可以不配置,在运行时不import,直接Class.forName("org.sqlite.JDBC"),用
javac -cp .:路径 类名,这样来运行。
4、用eclipse的话,就会你配置了CLASSPATH也找不到,要去工程的Propertries
--> Java Buid Path --> Libraries
下添加External JARs。这样eclipse才能够找到。
OK,连上了,就好说了。
2、放到磁盘里。一般放到JDK的lib下。
3、配置CLASSPATH路径。这里配置的/etc/profile文件。也可以不配置,在运行时不import,直接Class.forName("org.sqlite.JDBC"),用
javac -cp .:路径 类名,这样来运行。
4、用eclipse的话,就会你配置了CLASSPATH也找不到,要去工程的Propertries
--> Java Buid Path --> Libraries
下添加External JARs。这样eclipse才能够找到。
OK,连上了,就好说了。
推荐于2016-10-29 · 知道合伙人数码行家
huanglenzhi
知道合伙人数码行家
向TA提问 私信TA
知道合伙人数码行家
采纳数:117538
获赞数:517192
长期从事计算机组装,维护,网络组建及管理。对计算机硬件、操作系统安装、典型网络设备具有详细认知。
向TA提问 私信TA
关注
展开全部
方法如下:
1、去zentus官网下载驱动。
2、放到磁盘里。一般放到JDK的lib下。
3、配置CLASSPATH路径。这里配置的/etc/profile文件。也可以不配置,在运行时不import,直接Class.forName("org.sqlite.JDBC"),用 javac -cp .:路径 类名,这样来运行。
4、用eclipse的话,就会你配置了CLASSPATH也找不到,要去工程的Propertries --> Java Buid Path --> Libraries 下添加External JARs。这样eclipse才能够找到。
1、去zentus官网下载驱动。
2、放到磁盘里。一般放到JDK的lib下。
3、配置CLASSPATH路径。这里配置的/etc/profile文件。也可以不配置,在运行时不import,直接Class.forName("org.sqlite.JDBC"),用 javac -cp .:路径 类名,这样来运行。
4、用eclipse的话,就会你配置了CLASSPATH也找不到,要去工程的Propertries --> Java Buid Path --> Libraries 下添加External JARs。这样eclipse才能够找到。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
sqlite是android手机开发时候自带的一个小型的数据库的,只要你有安装android开发环境就可以在eclipse上面使用sqlite数据库
下面是例子(希望对你有帮助):
package yeshu.sqlite3;
import android.app.Activity;
import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
public class sqlite3 extends Activity {
private Button createdatabase;
private Button updatedatabase;
private Button insert;
private Button update;
private Button select;
private Button delete;
private EditText edittext01;
private EditText edittext02;
private String name;
private int id;
private String dbname;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
createdatabase = (Button) findViewById(R.id.xxx);
updatedatabase = (Button)findViewById(R.id.Button02);
insert = (Button)findViewById(R.id.Button03);
update = (Button)findViewById(R.id.Button04);
select = (Button)findViewById(R.id.Button05);
delete = (Button)findViewById(R.id.Button06);
edittext01 = (EditText)findViewById(R.id.EditText01);
edittext02 = (EditText)findViewById(R.id.EditText02);
createdatabase.setOnClickListener(new OnClickListener_create());
updatedatabase.setOnClickListener(new OnClickListener_updatedatabase());
insert.setOnClickListener(new OnClickListener_insert());
update.setOnClickListener(new OnClickListener_update());
select.setOnClickListener(new OnClickListener_select());
delete.setOnClickListener(new OnClickListener_delete());
}
class OnClickListener_delete implements OnClickListener
{
public void onClick(View v) {
// TODO Auto-generated method stub
id = Integer.parseInt(edittext01.getText().toString());
Data temp = new Data(sqlite3.this, "data_yeshu");
SQLiteDatabase db = temp.getWritableDatabase();
db.delete("user", "id=?", new String[]{id+""});
}
}
class OnClickListener_insert implements OnClickListener
{
public void onClick(View v) {
// TODO Auto-generated method stub
name = edittext02.getText().toString();
id = Integer.parseInt(edittext01.getText().toString());
Data temp = new Data(sqlite3.this, "data_yeshu");
SQLiteDatabase db = temp.getWritableDatabase();
ContentValues value = new ContentValues();
value.put("id", id);
value.put("name", name);
db.insert("user", null, value);
System.out.println("insert");
}
}
class OnClickListener_update implements OnClickListener
{
public void onClick(View v) {
// TODO Auto-generated method stub
name = edittext02.getText().toString();
id = Integer.parseInt(edittext01.getText().toString());
Data temp = new Data(sqlite3.this, "data_yeshu");
SQLiteDatabase db = temp.getWritableDatabase();
ContentValues value = new ContentValues();
value.put("name", name);
db.update("user", value, "id=?", new String[]{id+""});
}
}
class OnClickListener_updatedatabase implements OnClickListener
{
public void onClick(View v) {
// TODO Auto-generated method stub
Data temp = new Data(sqlite3.this, "data_yeshu", 2);
SQLiteDatabase db = temp.getReadableDatabase();
}
}
class OnClickListener_select implements OnClickListener
{
public void onClick(View v) {
// TODO Auto-generated method stub
Data temp = new Data(sqlite3.this, "data_yeshu");
SQLiteDatabase db = temp.getReadableDatabase();
Cursor cursor = db.query("user", new String[]{"id", "name"}, "id=?", new String[]{"1"}, null, null, null);
while(cursor.moveToNext())
{
System.out.println(cursor.getShort(cursor.getColumnIndex("id")));
System.out.println(cursor.getString(cursor.getColumnIndex("name")));
}
}
}
class OnClickListener_create implements OnClickListener
{
public void onClick(View v) {
// TODO Auto-generated method stub
Data temp = new Data(sqlite3.this, "data_yeshu");
SQLiteDatabase db = temp.getReadableDatabase();
}
}
}
================================
package yeshu.sqlite3;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;
public class Data extends SQLiteOpenHelper {
private static final int VERSION = 1;
public Data(Context context, String name, CursorFactory factory,
int version) {
super(context, name, factory, version);
// TODO Auto-generated constructor stub
}
public Data(Context context, String name, int version)
{
this(context, name, null, version);
}
public Data(Context context , String name)
{
this(context, name, null, VERSION);
}
@Override
public void onCreate(SQLiteDatabase db) {
// TODO Auto-generated method stub
System.out.println("create a new database");
db.execSQL("create table user(id int, name VERCHAR(20))");
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// TODO Auto-generated method stub
System.out.println("update a database");
}
}
下面是例子(希望对你有帮助):
package yeshu.sqlite3;
import android.app.Activity;
import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
public class sqlite3 extends Activity {
private Button createdatabase;
private Button updatedatabase;
private Button insert;
private Button update;
private Button select;
private Button delete;
private EditText edittext01;
private EditText edittext02;
private String name;
private int id;
private String dbname;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
createdatabase = (Button) findViewById(R.id.xxx);
updatedatabase = (Button)findViewById(R.id.Button02);
insert = (Button)findViewById(R.id.Button03);
update = (Button)findViewById(R.id.Button04);
select = (Button)findViewById(R.id.Button05);
delete = (Button)findViewById(R.id.Button06);
edittext01 = (EditText)findViewById(R.id.EditText01);
edittext02 = (EditText)findViewById(R.id.EditText02);
createdatabase.setOnClickListener(new OnClickListener_create());
updatedatabase.setOnClickListener(new OnClickListener_updatedatabase());
insert.setOnClickListener(new OnClickListener_insert());
update.setOnClickListener(new OnClickListener_update());
select.setOnClickListener(new OnClickListener_select());
delete.setOnClickListener(new OnClickListener_delete());
}
class OnClickListener_delete implements OnClickListener
{
public void onClick(View v) {
// TODO Auto-generated method stub
id = Integer.parseInt(edittext01.getText().toString());
Data temp = new Data(sqlite3.this, "data_yeshu");
SQLiteDatabase db = temp.getWritableDatabase();
db.delete("user", "id=?", new String[]{id+""});
}
}
class OnClickListener_insert implements OnClickListener
{
public void onClick(View v) {
// TODO Auto-generated method stub
name = edittext02.getText().toString();
id = Integer.parseInt(edittext01.getText().toString());
Data temp = new Data(sqlite3.this, "data_yeshu");
SQLiteDatabase db = temp.getWritableDatabase();
ContentValues value = new ContentValues();
value.put("id", id);
value.put("name", name);
db.insert("user", null, value);
System.out.println("insert");
}
}
class OnClickListener_update implements OnClickListener
{
public void onClick(View v) {
// TODO Auto-generated method stub
name = edittext02.getText().toString();
id = Integer.parseInt(edittext01.getText().toString());
Data temp = new Data(sqlite3.this, "data_yeshu");
SQLiteDatabase db = temp.getWritableDatabase();
ContentValues value = new ContentValues();
value.put("name", name);
db.update("user", value, "id=?", new String[]{id+""});
}
}
class OnClickListener_updatedatabase implements OnClickListener
{
public void onClick(View v) {
// TODO Auto-generated method stub
Data temp = new Data(sqlite3.this, "data_yeshu", 2);
SQLiteDatabase db = temp.getReadableDatabase();
}
}
class OnClickListener_select implements OnClickListener
{
public void onClick(View v) {
// TODO Auto-generated method stub
Data temp = new Data(sqlite3.this, "data_yeshu");
SQLiteDatabase db = temp.getReadableDatabase();
Cursor cursor = db.query("user", new String[]{"id", "name"}, "id=?", new String[]{"1"}, null, null, null);
while(cursor.moveToNext())
{
System.out.println(cursor.getShort(cursor.getColumnIndex("id")));
System.out.println(cursor.getString(cursor.getColumnIndex("name")));
}
}
}
class OnClickListener_create implements OnClickListener
{
public void onClick(View v) {
// TODO Auto-generated method stub
Data temp = new Data(sqlite3.this, "data_yeshu");
SQLiteDatabase db = temp.getReadableDatabase();
}
}
}
================================
package yeshu.sqlite3;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;
public class Data extends SQLiteOpenHelper {
private static final int VERSION = 1;
public Data(Context context, String name, CursorFactory factory,
int version) {
super(context, name, factory, version);
// TODO Auto-generated constructor stub
}
public Data(Context context, String name, int version)
{
this(context, name, null, version);
}
public Data(Context context , String name)
{
this(context, name, null, VERSION);
}
@Override
public void onCreate(SQLiteDatabase db) {
// TODO Auto-generated method stub
System.out.println("create a new database");
db.execSQL("create table user(id int, name VERCHAR(20))");
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// TODO Auto-generated method stub
System.out.println("update a database");
}
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
eclipse 里面有 sql exploer 这个插件 (名字好像拼写的不是很对)搜搜吧。
要是用myecplise的话 有 db browser 。
具体连接 按提示操作就可以了。。
要是用myecplise的话 有 db browser 。
具体连接 按提示操作就可以了。。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |