when i want to insert data into mysql using JdbcOdbc Bridge driver, i get no database selected error,

user5921748

i have created dsn correctly and have clear and simple code but i end up getting this error. the table structure is same as the program

   import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.Statement;
    public class Insert {
        public static void main(String[] args) {
            try {
                Class.forName("sun.jdbc.odbc.JdbcOdbc");
                Connection con=DriverManager.getConnection("jdbc:odbc:mysqldsn","root","filimon");
                Statement st=con.createStatement();
                int i=st.executeUpdate("insert into emp values(3,'cat')");
                if (i>=1) {
                    System.out.println("inserted successfully");
                } else {
                    System.out.println("failed");
                }
                st.close();
                con.close();
            } catch (Exception e) {
                System.err.println(e);
            }
        }
    }

I get java.sql.SQLException: [MySQL][ODBC 5.3(a) Driver][mysqld-5.7.13-log]No database selected

Abu Sufian

Error said that you haven't selected a database. But selection of the database would be somewhere in the ODBC configuration.

So you can do two things : Either you fix your ODBC configuration to select a database, or (a better option) you can stop using ODBC and use the MySQL JDBC driver.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Why i get error when want insert to table in sql server?

When connect to the database I get an error `driver not loaded`

I want to save data in DB using fill but I get an error

When inserting data into the database I get an error

How can I get the data from MySQL database based on the selected ID using bootstrap and Ajax?

Get error ProgrammingError when insert to MySQL database using Python

I want get data from MySQL using AJAX and show

First data not showing when I get data from a MySQL database

I want to insert members from php code into mysql database, it auto increment but no data is added

How can I insert data into a MySQL database?

SqlException error when I insert into database

Jmeter : Error when I try to get data from Database using beanshell assertion

When i try to delete a database it get a mysql error

I want to insert data into my dropdown list from database

I got the certificate error when I want to migrate my database

I want to get a data session and title but it is outside the loop when retrieving data from the database

I get a mysql error when using mysql_query()

Get error when trying to insert data into MySQL

Call must be made on main thread i can get the data but when i want it to show error message it crashes

I am using laravel 5.8, and I cannot insert data to mysql database

I want to get the selected radiobutton using saved prefrences but the activity is not opening?

After reading docx file, I want to insert the data in MySQL?

I have trouble when I try to insert datas into database in MySQL

Excel VBA - I want to insert a date in a 'Get external data' query

I want to get data from user and insert into db (SQL)

I get this error when i want to run my django app :

Connected to the database but through error when I try to insert into database table

In python script i have insert query but when i want insert multiple columns in the same query it gives error

I want to delete data from Realm database, but it gives me error