Connect database(Mysql) using Ejb3.0
Hi All,
Can any one give me an step by step procedure for entity beans it refers the mysql database's student table
thanks & regards,
Maheshwaran Devaraj
There's more that code involved. First off you need an implementation of the JPA (Java persistence API). Probably hibernate or toplink. The appropriate libraries have to go into your project (most of them can be runtime only but you need a library defining the JPA interfaces.).
You need a resource file called persistence.xml in the META-INF directory of your class tree or jar. That defines things like the database connection details, a list of entity classes and a set of options.
If you use an up to date IDE it will probably do most of this for you. Once it's set up you get an EntityManagerFactory instance and, from that, you get an EntityManager for each session from which you search for and otherwise manipulate entities. Generally you don't have to write any actual SQL, though you will probably have to write queries in a modified language called JPQL (Java Persistence Query Language).
Similar Messages
-
Need Help Connect to MySQL using dg4odbc
I am looking for some help getting a dblink working from my Oracle 11.1.0.6 Dtabase to a MySQL 5.0.77 Database (Holds Bugzilla).
This is the error I get when I try select * from "bugs"@bugz;
ORA-28500: connection from ORACLE to a non-Oracle system returned this message:
[MySQL][ODBC 5.1 Driver][mysqld-5.0.77]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"bug_id" FROM "bugs" A1' at line 1
ORA-02063: preceding 2 lines from BUGZ
On Server hosting Oracle DB:
lsb_release -id
Distributor ID: RedHatEnterpriseServer
Description: Red Hat Enterprise Linux Server release 5.7 (Tikanga)
rpm -qa|grep mysql
mysql-connector-odbc-5.1.8-1.rhel5
mysql-5.0.77-4.el5_6.6
tnsping BUGZ
TNS Ping Utility for Linux: Version 11.1.0.6.0 - Production on 08-DEC-2011 07:53:52
Copyright (c) 1997, 2007, Oracle. All rights reserved.
Used parameter files:
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))) (CONNECT_DATA = (SID = BUGZ)) (HS = OK))
OK (0 msec)
tnsnames.ora
BUGZ =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
(CONNECT_DATA =
(SID = BUGZ)
(HS = OK)
)listener.ora
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(ORACLE_HOME = /u00/app/oracle/product/11.1.0/db_1)
(SID_NAME = BUGZ)
(PROGRAM = dg4odbc)
(ENVS ="LD_LIBRARY_PATH=/u00/app/oracle/product/11.1.0/db_1/lib:/usr/lib64:/usr/lib")
.../u00/app/oracle/product/11.1.0/db_1/hs/admin/initbugz.ora
# This is a sample agent init file that contains the HS parameters that are
# needed for the Database Gateway for ODBC
# HS init parameters
HS_FDS_CONNECT_INFO=bugz
HS_FDS_TRACE_LEVEL=off
HS_FDS_SHAREABLE_NAME=/usr/lib64/libmyodbc5.so
HS_LANGUAGE=AMERICAN_AMERICA.WE8ISO8859P15
# ODBC specific environment variables
set ODBCINI=/u00/home/oracle/.odbc.ini
# Environment variables required for the non-Oracle system
set HOME=/u00/home/oracle
~/u00/home/oracle/.odbc.ini
[ODBC Data Sources]
[bugz]
Driver = /usr/lib64/libmyodbc5.so
DATABASE = bugzilla
DESCRIPTION = MySQL ODBC 5.x Connector
PORT = 3306
SERVER = bugzilla
UID = bugquery
PWD = password
CHARSET = latin1
TRACEFILE = /tmp/myodbc-bugzdsn.trc
TRACE = OFFODBC Test
isql -v bugz
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+---------------------------------------+
SQL> help bugs
[Bunch of stuff omitted]
SQLRowCount returns 31
31 rows fetched
SQL>I did the delete and reconnected and the rows where created again.
I am testing with two SQL statements right now from TOAD and from SQLPlus.
A. select bugs."bug_id" as Ticket, bugs."short_desc", bugs."bug_status" AS Status, bugs."assigned_to", dump(bugs."short_desc") from "bugs"@BUGZ bugs where "bug_id" = 2;
B. select bugs."bug_id" as Ticket, bugs."short_desc", bugs."bug_status" AS Status, bugs."assigned_to" from "bugs"@BUGZ bugs
When I issue "A" I get good looking results. When I issue "B" I get an error.
SQL> select bugs."bug_id" as Ticket, bugs."short_desc", bugs."bug_status" AS Status, bugs."assigned_to", dump(bugs."short_desc") from "bugs"@BUGZ bugs where "bug_id" = 2;
TICKET
short_desc
STATUS assigned_to
DUMP(BUGS."SHORT_DESC")
2
COMA computer has updates set to auto install please disable and allow me to ch
oose
CLOSED 8
Typ=1 Len=168: 0,67,0,79,0,77,0,65,0,32,0,99,0,111,0,109,0,112,0,117,0,116,0,101
TICKET
short_desc
STATUS assigned_to
DUMP(BUGS."SHORT_DESC")
,0,114,0,32,0,104,0,97,0,115,0,32,0,117,0,112,0,100,0,97,0,116,0,101,0,115,0,32,
0,115,0,101,0,116,0,32,0,116,0,111,0,32,0,97,0,117,0,116,0,111,0,32,0,105,0,110,
0,115,0,116,0,97,0,108,0,108,0,32,0,32,0,112,0,108,0,101,0,97,0,115,0,101,0,32,0
,100,0,105,0,115,0,97,0,98,0,108,0,101,0,32,0,97,0,110,0,100,0,32,0,97,0,108,0,1
08,0,111,0,119,0,32,0,109,0,101,0,32,0,116,0,111,0,32,0,99,0,104,0,111,0,111,0,1
TICKET
short_desc
STATUS assigned_to
DUMP(BUGS."SHORT_DESC")
15,0,101
SQL> select bugs."bug_id" as Ticket, bugs."short_desc", bugs."bug_status" AS Status, bugs."assigned_to" from "bugs"@BUGZ bugs;
ERROR:
ORA-28528: Heterogeneous Services datatype conversion error
ORA-02063: preceding line from BUGZ
no rows selectedThe bugs table looks like this:
CREATE TABLE `bugs` (
`bug_id` mediumint(9) NOT NULL auto_increment,
`assigned_to` mediumint(9) NOT NULL,
`bug_file_loc` mediumtext,
`bug_severity` varchar(64) NOT NULL,
`bug_status` varchar(64) NOT NULL,
`creation_ts` datetime default NULL,
`delta_ts` datetime NOT NULL,
`short_desc` varchar(255) NOT NULL,
`op_sys` varchar(64) NOT NULL,
`priority` varchar(64) NOT NULL,
`product_id` smallint(6) NOT NULL,
`rep_platform` varchar(64) NOT NULL,
`reporter` mediumint(9) NOT NULL,
`version` varchar(64) NOT NULL,
`component_id` smallint(6) NOT NULL,
`resolution` varchar(64) NOT NULL default '',
`target_milestone` varchar(20) NOT NULL default '---',
`qa_contact` mediumint(9) default NULL,
`status_whiteboard` mediumtext NOT NULL,
`votes` mediumint(9) NOT NULL default '0',
`lastdiffed` datetime default NULL,
`everconfirmed` tinyint(4) NOT NULL,
`reporter_accessible` tinyint(4) NOT NULL default '1',
`cclist_accessible` tinyint(4) NOT NULL default '1',
`estimated_time` decimal(7,2) NOT NULL default '0.00',
`remaining_time` decimal(7,2) NOT NULL default '0.00',
`deadline` datetime default NULL,
`alias` varchar(20) default NULL,
`cf_type` varchar(64) NOT NULL default '---',
`cf_notes` mediumtext,
`keywords` mediumtext NOT NULL,
PRIMARY KEY (`bug_id`),
UNIQUE KEY `bugs_alias_idx` (`alias`),
KEY `bugs_assigned_to_idx` (`assigned_to`),
KEY `bugs_creation_ts_idx` (`creation_ts`),
KEY `bugs_delta_ts_idx` (`delta_ts`),
KEY `bugs_bug_severity_idx` (`bug_severity`),
KEY `bugs_bug_status_idx` (`bug_status`),
KEY `bugs_op_sys_idx` (`op_sys`),
KEY `bugs_priority_idx` (`priority`),
KEY `bugs_product_id_idx` (`product_id`),
KEY `bugs_reporter_idx` (`reporter`),
KEY `bugs_version_idx` (`version`),
KEY `bugs_component_id_idx` (`component_id`),
KEY `bugs_resolution_idx` (`resolution`),
KEY `bugs_target_milestone_idx` (`target_milestone`),
KEY `bugs_qa_contact_idx` (`qa_contact`),
KEY `bugs_votes_idx` (`votes`),
CONSTRAINT `fk_bugs_assigned_to_profiles_userid` FOREIGN KEY (`assigned_to`) REFERENCES `profiles` (`userid`) ON UPDATE CASCADE,
CONSTRAINT `fk_bugs_component_id_components_id` FOREIGN KEY (`component_id`) REFERENCES `components` (`id`) ON UPDATE CASCADE,
CONSTRAINT `fk_bugs_product_id_products_id` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON UPDATE CASCADE,
CONSTRAINT `fk_bugs_qa_contact_profiles_userid` FOREIGN KEY (`qa_contact`) REFERENCES `profiles` (`userid`) ON UPDATE CASCADE,
CONSTRAINT `fk_bugs_reporter_profiles_userid` FOREIGN KEY (`reporter`) REFERENCES `profiles` (`userid`) ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=4570 DEFAULT CHARSET=utf8;Edited by: Sky13 on Dec 22, 2011 1:36 PM -
Problem connecting to Mysql using JDBC
Hi Everyone,
I am trying to connect Mysql ad java applet and I am using the Mysql jdbc connector.
I Took the mysql-connector-java-5.0.8-bin.jar file and put that in the library of jdk.
Now i used the following code to connect to the database using Netbeans.
package testmysql;
import java.sql.*;
public class Main
public static void main (String[] args)
Connection conn = null;
try
String userName = "root";
String password = "";
String url = "jdbc:mysql://localhost/rpms";
Class.forName ("com.mysql.jdbc.Driver").newInstance ();
conn = DriverManager.getConnection (url, userName, password);
System.out.println ("Database connection established");
catch (Exception e)
System.err.println ("Cannot connect to database server");
finally
if (conn != null)
try
conn.close ();
System.out.println ("Database connection terminated");
catch (Exception e) { /* ignore close errors */ }
But it displays Cannot connect to database server
thoughMysql server is running.
Can anyone tell me wats the prob in this.
thanksString url = "jdbc:mysql://localhost/rpms";
Class.forName ("com.mysql.jdbc.Driver").newInstance ();
Is rpms the MySQL database?
Is the database on the default port 3306?
Is the MySQL JDBC JAR file in the classpath of the applet?
newInstance() is not required to be invoked unless using <= JDK 2.0
Replace:
catch (Exception e)
System.err.println ("Cannot connect to database server");
with:
catch (Exception e)
System.err.println (e.getMessage());
Edited by: dvohra09 on Apr 10, 2009 10:54 PM
Edited by: dvohra09 on Apr 10, 2009 10:55 PM
Edited by: dvohra09 on Apr 10, 2009 10:58 PM -
Is it possible to connect to mysql using sun.jdbc?
Is it possible to connect to a mysql database using sun's jdbc:odbc driver?
I develop a page on the internet that uses mysql. The connection code is placed in a java class. I get the errormessage: "no suitable driver" when I try to connect with jsp/java classes.
If I use PHP it is ok.
Code:
$db = mysql_connect("localhost", "vegg", "nbvv2003");
mysql_select_db("vegg_timereg",$db);
$result = mysql_query("SELECT * FROM bruker",$db);The java code is like this:
java.sql.Connection conn = null;
String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
try {
Class.forName(driver);
conn = DriverManager.getConnection("jdbc:odbc:vegg_timereg","vegg","nbvv2003");
catch (SQLException e) {
out.print("<font color=red>Error:</font> SQLException<br>");
out.print(e.getMessage());
catch (ClassNotFoundException e) {
out.print("<font color=red>Error:</font> Driver not found<br>");
out.print(e.getMessage());
catch (Exception e) {
out.print("<font color=red>Error:</font> Error on initializing<br>");
out.print(e.getMessage());
}For me it does not seem like there are any drivers available in java, I've tried the sun.jdbc.odbc.JdbcOdbcDriver and org.gjt.mm.mysql.Driver. The mySql driver is missing, so that is the reason, but I do not get an error message when importing the jdbc:odbc driver.
I do not have permission to check the setup on the webserver:(
It runs Apache webserver.thx, but I don't seem to get any databases. It works when I run it locally, but on the external webserver it doesn't.
Database info:
Name: vegg_timereg
Place: localhost (root)
Type: mySQL
It doesn't seem like the mysql driver is installed on the server, so I have to use jdbc. I do not have any permissions on the server, so I can't check it out myself.
In PHP this connection works:
$db = mysql_connect("localhost", "vegg", "nbvv2003");
mysql_select_db("vegg_timereg",$db); I've tried like this (using java.sql.Driver): Class.forName("java.sql.Driver");
conn = DriverManager.getConnection("jdbc:localhost/vegg_timereg","username","password");This is really annoying when it's so easy on my machine... -
Problem in connecting Database by using SQL Developer
Hi,
I recently installed SQL Developer after installing Oracle 10g and am trying to connect existing database. could anybody help me to connect and what credential should i required to connect.
Thanks in advance
LN ReddyI am new to oracle myself, so I apologize if this information is not helpful. But I have a number of connections to a local database on my laptop. The way that I connected is using the 'Basic' tab with the following settings:
Hostname: localhost
Port: 1521
SID: orcl
And of course the username above.
I hope that might be helpful. -
Unable to connect to mysql using JSP servlet
Respected Sir/Madam
I have made a jsp application and use tomcat 4 and mysql .Whenever there is a db connection the application tries to connect.but then it throws exception
java.sql.SQLException: Unable to connect to any hosts due to exception: java.net.ConnectException: Connection timed out: connect
This error started occuring all of a sudden and i am not getting its root cause...Can anybody help me out of this...?
I am having intranet. And one thing that amazed me was when I send request for that JSP page from different machine then it connected to db without any error..Only when I request that JSP page from my machine it is giving me this error.
Please help..
Waiting for your reply.
Thanks and RegardsMicrosoft Telnet> open Oracleserver
Connecting To Oracleserver...Could not open a
connection to host: Connect failedYou need to run the exact command i gave you from the command line. There may not be a telnet server running on OracleServer, you are trying to connect to port 23 with the command above.
run 'telnet Oracleserver 3306'
If this does not work, try the same thing with the IP address instead of 'Oracleserver', you may have a name resolution issue.
I didnt understood this .I also tried running this
command from other machines where my application is
running fine. But there also the same error.
I gave proper URL and user name and password for mysql
String dsnString="jdbc:mysql://Oracleserver/test";FYI - this will use the default port, I usually explicitly provide it (OracleServer:3306). Why don't you try the URL in the format I gave you above, including the user id and password?
-Scott -
Error showing when connecting to MySQL using servlet
This is my Program. (MySQL.java)
package coreservlets;
import java.sql.*;
public class MySQL {
public static void main (String[] args) {
String driver = "com.mysql.jdbc.Driver";
String url = "jdbc:mysql://localhost/leave_app";
String username = "";
String password = "";
showEmployeeTable(driver, url, username, password);
public static void showEmployeeTable(String driver,
String url,
String username,
String password)
try{
Class.forName(driver);
Connection connection = DriverManager.getConnection(url, username, password);
Statement statement = connection.createStatement();
String query = "Select userid from userlogin";
ResultSet resultSet = statement.executeQuery(query);
while(resultSet.next()){
System.out.print(resultSet.getString("userid"));
connection.close();
} catch(ClassNotFoundException cnfe) {
System.err.println("Error loading driver: " + cnfe);
} catch(SQLException sqle) {
System.err.println("Error with connection: " + sqle);
Error showing
java.lang.ClassCastException: coreservlets.MySQL cannot be cast to javax.servlet.Servlet
org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java:370)
org.apache.catalina.servlets.InvokerServlet.doGet(InvokerServlet.java:134)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
Could someone help me to resolve this bug?Hi,
I think you have misunderstood me. What I'm trying to say is that your MySQL.java doesn't seems to be the root cause of the problem.
The way you invoke the MySQL.java. may be the cause of the problem.
As from your implementation, your MySQL.java seems to be a plain java application. However, it seems that you are trying to treat MySQL .java as a servlet.
My guess this that you wanted to do something like this:
class MySQL extends HttpServlet {
public void doPost(..... ) {
//the codes in the main method to be put in this method.
public void doGet( ....) {
doPost(....)
//some of your other methods put here.
}For more information on how to write a servlet, you may visit http://java.sun.com/developer/onlineTraining/Programming/BasicJava1/servlet.html -
Connecting to mysql database using DBLOGIN
I am trying to connect to a mysql database through GG command interface and am unable to get the DBLOGIN to work correctly. Here is what I am getting:-
mysql world -u root -p<password> (as user OS user mysql- works!)
GGSCI (rac1) 5> DBLOGIN SOURCEDB world, USERID root, PASSWORD <password>
2010-11-08 16:29:17 WARNING OGG-00769 MySQL Login failed: . SQL error (2002). Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2).
ERROR: Failed to connect to MySQL database engine for HOST localhost, DATABASE world, USER root, PORT 0.
I am not too familiar with mysql and will appreciate help and also pointer to documents that walk through setting up and testing Golden Gate with mysql.
Thanks,
Satishhi.
i have same problem can't connect to mysql using dblogin on ggsci, please helpme
this my.cnf configuration
# Example MySQL config file for small systems.
# This is for a system with little memory (<= 64M) where MySQL is only used
# from time to time and it's important that the mysqld daemon
# doesn't use much resources.
# You can copy this file to
# /etc/my.cnf to set global options,
# mysql-data-dir/my.cnf to set server-specific options (in this
# installation this directory is /var/lib/mysql) or
# ~/.my.cnf to set user-specific options.
# In this file, you can use all long options that a program supports.
# If you want to know which options a program supports, run the program
# with the "--help" option.
# The following options will be passed to all MySQL clients
[client]
#password = your_password
port = 3306
socket = /tmp/mysql.sock
#socket = /var/run/mysqld/mysqld.sock
# Here follows entries for some specific programs
# The MySQL server
[mysqld]
port = 3306
socket = /tmp/mysql.sock
#socket = /var/run/mysqld/mysqld.sock
skip-locking
key_buffer_size = 16K
max_allowed_packet = 1M
table_open_cache = 4
sort_buffer_size = 64K
read_buffer_size = 256K
read_rnd_buffer_size = 256K
net_buffer_length = 2K
thread_stack = 128K
# Don't listen on a TCP/IP port at all. This can be a security enhancement,
# if all processes that need to connect to mysqld run on the same host.
# All interaction with mysqld must be made via Unix sockets or named pipes.
# Note that using this option without enabling named pipes on Windows
# (using the "enable-named-pipe" option) will render mysqld useless!
#skip-networking
server-id = 1
# Uncomment the following if you want to log updates
#log-bin=mysql-bin
# binary logging format - mixed recommended
#binlog_format=mixed
# Uncomment the following if you are using InnoDB tables
#innodb_data_home_dir = /var/lib/mysql/
#innodb_data_file_path = ibdata1:10M:autoextend
#innodb_log_group_home_dir = /var/lib/mysql/
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
#innodb_buffer_pool_size = 16M
#innodb_additional_mem_pool_size = 2M
# Set .._log_file_size to 25 % of buffer pool size
#innodb_log_file_size = 5M
#innodb_log_buffer_size = 8M
#innodb_flush_log_at_trx_commit = 1
#innodb_lock_wait_timeout = 50
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates
[myisamchk]
key_buffer_size = 8M
sort_buffer_size = 8M
[mysqlhotcopy]
interactive-timeout -
Trouble creating a database in MySQL using java
Hi all,
I am trying to create a program that connects to MySQL and can create databases, tables etc. I can connect to MySQL using the program but I cannot create a database (however if i create the database with the command line i can create tables in the database).
When I try to create a database i get the error
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown database 'persondatabase'Here is the code:
import java.sql.*;
class Connect {
public Connect() {
public Connection connectToMySQL(String database_name) {
Connection con = null;
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
con = DriverManager.getConnection("jdbc:mysql:///persondatabase", "", "");
catch(ClassNotFoundException e) { System.out.println(e); }
catch(InstantiationException e) { System.out.println(e); }
catch(SQLException e) { System.out.println(e); }
finally {
return con;
public void createDatabase(String database_name) {
Connection con = null;
Statement stmt = null;
try {
con = connectToMySQL(null); //connect to mysql but not to any one databases
con.setAutoCommit(false);
if(!con.isClosed())
System.out.println("Connected to MySQL. Creating the Database " + database_name);
String str = "CREATE DATABASE " + database_name;
stmt = con.createStatement();
stmt.executeUpdate(str);
con.commit();
catch (Exception e2) { }
finally {
try {
stmt.close();
con.close();
}catch (Exception e3) { }
public void createPersonDetailsTable(String database_name, String table_name) {
Connection con = null;
Statement stmt = null;
try {
con = connectToMySQL(database_name);
con.setAutoCommit(false);
if(!con.isClosed())
System.out.println("Connected to " + database_name + " creating the table " + table_name);
String str = "CREATE TABLE " + table_name + "(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, first_name VARCHAR(25), last_name VARCHAR(25), address VARCHAR(40), suburb VARCHAR(20), state VARCHAR(3), post_code INT(1), contact_number INT(10), email_address VARCHAR(40));";
stmt = con.createStatement();
stmt.executeUpdate(str);
con.commit();
catch (Exception e2) { System.out.println(e2); }
finally {
try {
stmt.close();
con.close();
}catch (Exception e3) { }
}I am wondering if anyone can see where im going wrong? I am currently connecting with an anon account to MySQL.
Here is the program I am using to test the above:
class ConnectionTester {
public ConnectionTester() {
Connect s = new Connect();
s.createDatabase("PersonDatabase"); //this throws the error
//s.createPersonDetailsTable("PersonDatabase", "PersonDetails");
public static void main(String[] arg) {
ConnectionTester start = new ConnectionTester();
}you should rethink whether you need to create a database using java. personally i think it's a bad idea. your database should exist and the schema should be ready to go when your app starts. why do you think you need to create one?
% -
Can't connect to MySQL from Oracle 11g R1
Hello Oracle's guru.
Sorry for my English it's not my native langauge
Enviroments: Oracle 11g R1, Windows 7, ODBC Driver 5.1.8
I have a some problem with creation gateway to connection to MySQL, and I hope somebody can help me.
So,
1) ODBC name - MYSQLDSN
2) initMYSQLDSN.ora
# This is a sample agent init file that contains the HS parameters that are
# needed for the Database Gateway for ODBC
# HS init parameters
HS_FDS_CONNECT_INFO = MYSQLDSN
HS_FDS_TRACE_LEVEL = 0
3) listener.ora
# listener.ora Network Configuration File: E:\app\voxa\product\11.1.0\db_1\network\admin\listener.ora
# Generated by Oracle configuration tools.
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
SID_LIST_LISTENER=
(SID_LIST=
(SID_DESC=
(SID_NAME=MYSQLDSN)
(ORACLE_HOME=E:\app\voxa\product\11.1.0\db_1)
(PROGRAM=dg4odbc)
4) tnsnames.ora
# tnsnames.ora Network Configuration File: E:\app\voxa\product\11.1.0\db_1\network\admin\tnsnames.ora
# Generated by Oracle configuration tools.
CXWH =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = CXWH)
MYSQLDSN =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521))
(CONNECT_DATA =(SID = MYSQLDSN))
(HS = OK)
Then I trying to connect to MySQL using sql*plus:
C:\Windows\system32>sqlplus
SQL*Plus: Release 11.1.0.6.0 - Production on Ср Июн 1 12:13:39 2011
Copyright (c) 1982, 2007, Oracle. All rights reserved.
login: system
pass:
Connect to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> create public database link MYSQLDSN
2 connect to DEMO identified by "DEMO" using 'MYSQLDSN';
Channel was created
SQL> select * from items@MYSQLDSN;
select * from items@MYSQLDSN
Error in line 1:
ORA-28500: connection with ORACLE with other system return message:
[MySQL][ODBC 5.1 Driver][mysqld-5.5.12]You have an error in your SQL syntax;
check the manual that corresponds to your MySQL server version for the right
syntax to use near
'"ITEMS_KEY",A1."ITEM_NAME",A1."ITEM_CATEGORY",A1."ITEM_VENDOR",A1."ITEM_SKU",A1
.' at line 1
ORA-02063: предшествующий 2 lines из MYSQLDSN
If I trying create new ODBC mobule via OWB, I had next error:
[MySQL][ODBC 5.1 Driver][mysqld-5.5.12]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"DUAL"' at line 1
ORA-02063: предшествующий 2 lines из OWB_56
What I do wrong? Please help meHi,
You can download the 11.1.0.7 patchset from My Oracle Support -
support.oracle.com
as patch 6890831.
Once logged in click on 'Patches and Updates' and enter the patch number as 6890831 and choose whichever platform you are running.
the readme explains how to apply the patch to an existing 11.1.0.6 install.
The url you posted is only for complete product installs, but 11.1.0.7 is only a patchset that must be applied to an existing install.
Regards,
Mike -
How can i work with Mysql using socket
hi
When i connect through mysql using socket
then can i send a query to mysql through socket.
if yes then how
retrive data which is performed by query
plz help me
THANKSnot like its not possible, but you better refer to JDBC instead of plain socket... its much easier and its already been done...
google for mysql jdbc tutorial or something... -
Jakarta-tomcat-3.3.2 connection with mysql-4.1.12a-win32
how do i connect to mysql using tomcat?
i've set the class path = ".;D:\j2sdk1.4.2_08\jre\lib\ext\mysql-connector-java-3.1.10-bin.jar;"
without quotes
i've copy the mysql-connector-java mysql-connector-java-3.1.10-bin.jar into the mentioned directory = "D:\j2sdk1.4.2_08\jre\lib\ext\"
and my computer's mysql 's service is starting since my computer restart [i've checked it by right click desktop toolbar->Task Manager->Processes->mysqld-nt.exe..
and i've used the code from :
http://www.stardeveloper.com/articles/display.html?article=2003090201&page=4
to test if my connection is active, my JdbcExample1.java file is located at D:\jakarta-tomcat-3.3.2\webapps\ROOT\WEB-INF\classes\com\example, so my source code is :
package com.example;
import java.sql.*;
public class JdbcExample1 {
public static void main(String args[]) {
Connection con = null;
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
con = DriverManager.getConnection("jdbc:mysql:///test", "root", "nothing");
if(!con.isClosed())
System.out.println("Successfully connected to MySQL server...");
} catch(Exception e) {
System.err.println("Exception: " + e.getMessage());
} finally {
try {
if(con != null)
con.close();
} catch(SQLException e) {}
when i compile the file using javac, it's fine, when i run it using java, it shows me this error:
Exception in thread "main" java.lang.NoClassDefFoundError: JdbcExample1 (wrong n
ame: com/example/JdbcExample1)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:539)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:12
3)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:251)
at java.net.URLClassLoader.access$100(URLClassLoader.java:55)
at java.net.URLClassLoader$1.run(URLClassLoader.java:194)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
what have i missed out? anyone can u please help me? is my coding or setting in-accurate? thanks for reviewing my topics tooI'm not sure why you have mentioned Tomcat, but you need to run the class with something like:
java -classpath .;D:\j2sdk1.4.2_08\jre\lib\ext\mysql-connector-java-3.1.10-bin.jar com.example.JdbcExample1If you've correctly set the CLASSPATH environment variable then you can leave out the -classpath command line argument. Notice that you must specify the package of the class too.
To compile this all correctly, you should do something like:
mkdir classes
javac -d classes JdbcExample1.javaand then run with
java -classpath classes;D:\j2sdk1.4.2_08\jre\lib\ext\mysql-connector-java-3.1.10-bin.jar com.example.JdbcExample1 -
Unable to connect to MySQL Database using MX
I am unable to connect to MySQL database hosted on a remote
server. I get the following error message:
"HTTP Error Code 404 File Not Found. Here are some possible
reason for the problem:
1) There is no testing server running on the server machine.
2) The testing server specified for this site does not map to
the
http://72.9.255.2/~keyitems/_mmServerScripts/MMHTTPDB.php
URL. Verify that the URL Prefix maps to the root of the site."
I have specified a testing server. My url is "
http://72.9.255.2/~keyitems/........."
For the URL prefix to the site's root folder, I listed the
following:
1.
http://72.9.255.2/~keyitems/
this did not work. I got the above error message.
2.
http://72.9.255.2/ this did not work
also. I got the above error message.
Any input would be great as I do not know where to start !!!
Thank youHi Ravi
Glad to hear you solved this. It is very gratifying when one solves it alone, don't you think?
Best wishes
Michael -
Error in connecting to mysql database using jsp
Hi
I've encountered this error:
java.lang.ClassNotFoundException: org.gjt.mm.mysql.Driver
while trying to connect to MySQL db.
I've downloaded the driver from www.mysql.com, and set the classpath as: "C:\mm.mysql.jdbc-1.2b;%CLASSPATH%;"
But it juz doesn't seem to work...
Can someone pls help me?These are my settings in autoexec.bat:
SET PATH=C:\PROGRA~1\ABRIAS~1\ABRIAS~1\PERL\BIN;%PATH%;
SET JAVA_HOME=C:\jdk1.3.1
SET TOMCAT_HOME=C:\Tomcat3.2.3
SET CLASSPATH=C:\mm.mysql.jdbc-1.2b;%CLASSPATH%;
Well, i'm quite new to jsp so i'm not sure what u meant by "In the servlet container's init scripts?". I onli did the settings above and reset my server.
I've tried checking the dir...and yes there's a dir named org.
Any ideas wat can possibly be wrong??? -
I can't connect to MySQL database from The JSP Standard Tag Library
Hi All !
I have a problem, please help me anybody !
I don't connect to MySQL database from jsp page using JSTL tag but from servlet all work correctly. I set my path and put �mysql-connector-java-3.1.13-bin.jar� in ENVIRONMENT WinXP(classpath=C:\Java\jdk1.5.0_10\jre\lib\ext\mysql-connector-java-3.1.13-bin.jar) and in War project folder �WEB-INF/lib� and in [TomcatServer]\common\lib.
I have in folder�WEB-INF/lib� following files:
antlr.jar
commons-beanutils.jar
commons-collections.jar
commons-digester.jar
commons-fileupload.jar
commons-logging.jar
commons-validator.jar
jakarta-oro.jar
jsf-api.jar
jsf-impl.jar
jstl.jar
mysql-connector-java-3.1.13-bin.jar
standard.jar
struts.jar
I'm using:
NetBeans 5.5 Build200610171010 (bundled Tomcat 5.5.17)
Ent.Pack 20061020 Visual Wb Pack 061103
OS WinXP SP2
Java 1.5.0_10
MySQL 5.0.18-nt
1:<%@page contentType="text/html"%>
2:<%@page pageEncoding="UTF-8"%>
8: <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
9: <%@taglib uri="http://java.sun.com/jstl/sql" prefix="sql"%>
10:
11: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
12: "http://www.w3.org/TR/html4/loose.dtd">
13:
14: <sql:setDataSource var="ds"
15: driver="com.mysql.jdbc.Driver"
16: url="jdbc:mysql://localhost:3306/test"
17: user="root"
18: password="xxxx"/>
19:
20:
21:<sql:query sql="select name, age from People" var="res"
22: dataSource="${ds}"/>
I have received report on mistake when entered code at the top:
�/index.jsp [21;0] According to TLD or attribute directive in tag file, attribute dataSource does not accept any expressions�
I used instead of (dataSource="${ds}")->(dataSource="ds") but this did not work.
After build and run I have received
=========================================START=================================
HTTP Status 500
type Exception report:
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: /index.jsp(21,0) According to TLD or attribute directive in tag file, attribute dataSource does not accept any expressions
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)
root cause
org.apache.jasper.JasperException: /index.jsp(21,0) According to TLD or attribute directive in tag file, attribute dataSource does not accept any expressions
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:39)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:405)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:146)
org.apache.jasper.compiler.Validator$ValidateVisitor.checkXmlAttributes(Validator.java:955)
org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:710)
org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1441)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2213)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2219)
org.apache.jasper.compiler.Node$Root.accept(Node.java:456)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
org.apache.jasper.compiler.Validator.validate(Validator.java:1489)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:166)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:276)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:264)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:303)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.17 logs.
Apache Tomcat/5.5.17
=======================================END================================
Error: "According to TLD or attribute directive in tag file, attribute dataSource does not accept any expressions" - but according to documentation such parameter possible.
BUT WHEN JOINING With DATABASE FROM SERVLET ALL WORK FINE.
I read this doc - [http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html], this applicable if I Tomcat Admin, but i'am not Admin
I simply user, i.e. I want to place its database on virtual host (Tomcat+(JSP-JSTL)+MySQL).
There is idea how can resolve this problem
Thank you in advance ;)For all how have similar problem.
Decision instead of these ways
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ taglib prefix="sql" uri="http://java.sun.com/jstl/sql" %>
it is necessary to indicate these
<%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
Maybe you are looking for
-
i am unable to download updates for my iphone 4 using my pc. i have turned off firewall and spam however the downloadkeeps stopping about halfway through saying i have been disconnected from the network and to check my settings. very frustrating! hel
-
HT5628 Installing Windows 8 using an upgrade disc?
I'm currently not using Boot Camp at all. I have a Windows XP SP1 install disc (legal copy). I'm looking at buying the Windows 8 upgrade. Without having any Windows OS currently installed, can I use the Windows 8 upgrade to install Windows? I know in
-
I have an Ipad 2 that I use to view an IP camera over a Wifi network. The Ipad is in a vehicle that leaves the Wifi range and then returns to the range. Upon returning to the range, the Ipad has trouble connecting to the network. (30 seconds) The
-
Repairing Permissions With DU -Vs- MainMenu
Hello, I was curios does it matter if I repair permissions with disk Utility versus repairing them with Main Menu Pro version? Also will it hurt doing system maintenance using Main Menu. I know Main Menu is 3rd party, but I think it has been around l
-
Portal connectivity issue through VPN
Dear Experts, I have an issue in getting connected to Portal through VPN. I have maintained hosfile entries in the system also but still i am unable to connect to portal. when i ping from the same system it is getting pinged. out of doubt i checked w