Connecting to a MySQL Database with Java to insert data in table - mysql

I have a problem inserting data to my mysql database table. I have an error :
Exception in thread "main" java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Could not find output table 'book'.
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6956)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7113)
at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(JdbcOdbc.java:3109)
at sun.jdbc.odbc.JdbcOdbcStatement.execute(JdbcOdbcStatement.java:337)
at sun.jdbc.odbc.JdbcOdbcStatement.executeUpdate(JdbcOdbcStatement.java:287)
at connectTest.ConnectTest.insertPerson(ConnectTest.java:55)
at connectTest.ConnectTestDemo.main(ConnectTestDemo.java:16)
Java Result: 1
I don't know why could not find my table.
I have created that in mysql database.

Please provide your source code and configuration file so that I can help you better.
Can you correctly connect to the database? You said you are using MYSQL database but I see you are using MS Access ODBC driver for the connection. If that is the case I recommend you use the MYSQL JDBC driver which you can download from
http://dev.mysql.com/downloads/connector/j/
If you can connect to the database correctly, then you may have not set your database schema (database name) properly.
Please provide your source code and configuration file so that I can help you better.
For an example of how you should configure db using pure JDBC have a look at this link:
http://www.tutorialspoint.com/jdbc/jdbc-insert-records.htm
Basically you provide a connection url in the format jdbc:mysql://[MySQLServer_DOMAIN_NAME_OR_IP_ADDRESS]:[PORT]/[DB_NAME].

Related

Oracle database error 12514: ORA-12514: TNS:listener does not currently know of service requested in connect descriptor

Now I am using Tableau business intelligence tool for data visualization,i tried to connect Oracle database with tableau,at that time i got below Error'
Unable to connect to the server. Check that the server is running and that
you have access privileges to the requested database.
Oracle database error 12514: ORA-12514: TNS:listener does not currently
know of service requested in connect descriptor
Unable to connect to the Oracle server "192.176.10.145". Check that the
server is running and that you have access privileges to the requested
database.
in what mistake i did,kindly help me out ,give any suggestion to resolve this
Here is an article from tableau which suggests that the ORA-12514 error occurs when SERVICE value is incorrect.
To resolve this issue, find out what the correct SERVICE value is, open the TNSNames.ora file located in your %ORACLE_HOME%\network\admin\ folder. Refer to the steps under ORA_12154 if necessary.

SSIS No Tables or Views Could be Loaded Error with Oracle 12c ODBC

We are trying to set up an ODBC Destination object in a SSIS package and getting a "No tables or views could be loaded" error (see screen shot below). The schema is relatively new and we are able to do this with an older schema in the same database.
Some observations:
We are able to successfully make a connection to the schema both through the Windows ODBC administrator and from the SSIS connection manager.
We are able to display tables from ANOTHER schema that is the same database.
We are also able to display tables in the schema causing the error if we do so by connecting to another schema (see more below).
More on #3 above. Let's say we have schemas/users MySchemaA and MySchemaB and MySchemaB is the one we want. If we connect directly to MySchemaB, it doesn't work. But if we grant MySchemaA rights to see tables in MySchemaB and connect to MySchemaA... we can indirectly see the tables granted in MySchemaB through the connection to MySchemaA. Hopefully clear as mud.
Any ideas how to fix this?
Since this is a new schema, does something need to be setup on the DB side to allow this?
We using Oracle 12c and have installed the necessary drivers. Also using ODBC administrator 32-bit to set up a system DSN.

Talend MySQl Database error

I am trying to create a new database connection in talend studio and it is showing me this error:
Connection failure. You must change your database settings.
I have configured MySQl installer and also I have searched about this error and saw some answers but neither of them were clear, how can I fix this problem.
The exception thrown says that Talend was unable to connect to the database "demo". Try to create a database with the name "demo" with another SQL tool before connecting to it with talend.

Connecting to a MySQL db with the anylogic objects

I'm trying to connect to a local MySQL database, with the anylogic object "database".
I'm using the type: "Other Database", and the connection URL: "Server=localhost;Database=anylogicdata;"
but I constantly get a RuntimeException saying: "not suitable driver found"
The help file says that you have to install the driver, but i don't know which or if it is my connection URL that is the problem.
Does anyone have some pointers to help me along the way?
You need a JDBC driver to be able to connect to a MySQL server from Java (that AnyLogic is based on) and you can find one here. After you have installed the driver you should find it in the list of available JDBC drivers in AnyLogic. The name should be com.mysql.jdbc.Driver if you chose the suggested one.
First you have to download and add the mysql-connector-java-*.jar file to the anylogic-project.
Then you have to type com.mysql.jdbc.Driver into the JDBC driver dropdown box. finally the connection string should look something like
jdbc:mysql:[host/db]?:[port]
another thing I found that might be helpfull to others, is that you can get the java connection from the anylogic db object: database.getConnection() this is very usefull if you want to create your own query. eg create a bulk insert instead of the single insert that Anylogic provides.

Trying to migrate SQL Server to MySQL using MySQL Workbench. Error: "[Microsoft][ODBC Driver Manager] Invalid argument value" when migrating data

Long time lurker, first time poster; hoping anyone can help me out.
Im using MySQL Workbench 5.2.41 to migrate a database from SQL Server to MySQL 5.0.8
The entire process goes smoothly: both SQL and MySQL connection Tests are good, the skemea and table create as expected, everything checks out until the 'Bulk Data Transfer' step. At that point I receive this error:
...
Migrating data...
wbcopytables.exe --odbc-source=DSN=SQL Server 11;DATABASE=;UID=sa --target=root#127.0.0.1:3306 --progress --passwords-from-stdin --thread-count=1 --table [GSAClosers_v2] [dbo].[AccountBase] `dbo` `AccountBase`
`dbo`.`AccountBase`:Copying 84 columns of 169530 rows from table [GSAClosers_v2].[dbo].[AccountBase]
ERROR: `dbo`.`AccountBase`:SQLGetData: HY009:10:[Microsoft][ODBC Driver Manager] Invalid argument value `dbo`.`AccountBase`:
Finished copying 0 rows in 0m00s
Copy helper has finished
...
For connectors I'm using Microsoft SQL Server / ODBC Data Source / DSN: SQL Server and for MySQL the IP and port(3306).
SQL Server 2012 Management Studio connects and all operations work as expected.
O, side not: both are on the same localhost machine.
If anyone can shed some light on this I would be forever indebted. Thanks in advance
From here:
[Microsoft][ODBC Driver Manager] Invalid argument value.
Regarding to the error message and code you provided, which seems is
database is invalid or cannot be accessed. That means either the
database does not exist or the user does not have permission to access
the database.
It turns out you need specify the instance after the server name, so
in the server name in the dialog box for creating the ODBC Data
Source, you must enter it as either: MyServer\SQLEXPRESS or
.\SQLEXPRESS
I think you may have a problem connecting to your database from wbcopytables.exe. Keep in mind that this is a separate tool so the fact that you can connect from the rest of the Migration Wizard doesn't imply that you will connect in wbcopytables.exe.
The thing that worries me the most is that your DSN has whitespace characters. This might be interpreted by the Windows terminal as independent command line parameters. One thing you can do is to edit your DSN name removing the whitespaces and try again.
You may also want to connect without a DSN by putting all your connection parameters explicitely as explained in my blog post: How-To: Guide to Database Migration from Microsoft SQL Server using MySQL Workbench.
And, by the way, since MySQL Workbench 5.2.42 is out you should go and get it. The Migration Wizard is pretty new so important bug fixes are likely launched in each recent Workbench release.
In either case I think you should file a bug with your issues with a detailed explanation about how to reproduce it, possible solutions, etc.
Hope this helps.
Ok, got it figured out: un-install java. install java 1.6, use MySQL Migration Tool. change all data types to varchar, ints and bits. run migrations....eat data.