How to use JDBC with IDEA community edition

Hello all,

I'm new with IntelliJ IDEA, and I was trying to use a jdbc driver inside an Android project. I was searching info but all I find was specific to the ultimate version, not community. How can I configure the project to use that driver?

More detailed info:
- IntelliJ IDEA v. 10.5.2
- First I created an Android Module, using Java SDK 1.6 and Android SDK 2.2
- I have the postgresql-9.1-901.jdbc4.jar file with the JDBC driver
- ¿Where must I copy the .jar file of that driver for being usable by the project? (I tried on the project's root path, on the src, res and libs folders, and finally on external libraries, inside Android 2.2 platform, with android.jar)

I run the following code to test, but the driver is not accesible (the layout has a button for "login", if the jdbc driver is not found, the button text is "Can't find JDBC driver", otherwyse it will be "Login"):


package com.sample.test1;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import java.util.Date;
import java.sql.*;

public class test1 extends Activity implements View.OnClickListener
{
    Button btn;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        btn=(Button)findViewById(R.id.btn_login);
        btn.setOnClickListener(this);
        updateTime();

        try {

            Class.forName("org.postgresql.Driver");
        } catch(ClassNotFoundException e){
            btn.setText("Can't Find JDBC driver");
            e.printStackTrace();
            return;
        }

..............


Thanks.

Please sign in to leave a comment.