score:0
Accepted answer
username and password needs to be passed to the getconnection() eg.
connection conn = null;
string url = "jdbc:mysql://localhost/";
string dbname = "somedb";
string driver = "com.mysql.jdbc.driver";
string username = "root"; string password = "password";
try { class.forname(driver).newinstance();
conn = drivermanager.getconnection(url+dbname,username,password); system.out.println("connected to the database"); conn.close(); system.out.println("disconnected from database"); } catch (exception e) { system.out.println("no connection =("); } }
Source: stackoverflow.com
Related Query
- Error occur while connecting to database mysql workbench:java.sql.SQLNonTransientConnectionException: Could not create connection to database server
- sql statement error while connecting with db2 using eclipse juno
- Error While connecting to SQL server in android application using eclipse
- BIRT report error when connecting to MySql database
- Getting "The filename, directory name, or volume label syntax is incorrect" error while connecting to MySQL (wamp server) from JAVA (eclipse)
- Error or wrong type of code while creating connection & execute SQL query statements using mysql in java
- Connecting a MySQL database to Glassfish classpath is not set or classname is wrong
- (Eclipse SDK update error) An error occur while collecting items to be installed
- getting Error "java.lang.ExceptionInInitializerError" while trying to access mysql local intance in App engine project
- error when connecting to remote MySQL (host gator) server using JDBC
- Connecting a Java application to an SQL database with Eclipse
- Error while connecting to Oracle DSN using Java
- Connecting Java in Windows/Eclipse to a ScotchBox Vagrant Box MySQL Database
- Error while connecting to ClearCase(CCRC) via STS eclipse
- Error while Creating SQLCiphered database on sdCard in android
- Java Connecting to remote MySQL database
- Error create SQL model connection. Eclipse to mysql
- I can't retrieve data from MySQL database using a JSP file and receive a java.math.BigInteger cannot be cast to java.lang.Long error
- MyEclipse Professional on connecting with ms sql server is giving ssl error through db browser
- Error while executing SQL query in Eclipse
- Internal error while connecting to google play services
- Access Denied when connecting to MySQL database in Java
- Eclipse Inserting Data into MySQL with a while loop no value specified error
- MySQL Database not connecting to Android app
- Could not create connection to database server - Eclipse MySQL error
- Error in connecting Eclipse to SQL Server
- JBoss server exception while connecting to mysql
- Error while connecting Eclipse IDE to run the Flex 4.5.1 SDK
- Error when updating MySQL database using UPDATE - SET - WHERE method in Eclipse
- Error while trying to start MySQL
More Query from same tag
- Eclipse Auto Save before build?
- java.lang.IllegalArgumentException: Document base [...]org.eclipse.wst.server.core\tmp0\wtpwebapps[...] does not exist or is not a readable directory
- Basic android with eclipse : the process android.process.acore has stopped unexpectedly
- Eclipse with ADT performance issue
- Help with creation of refactoring plugins in Eclipse?
- Disabling a row in tableviewer in eclipse e4
- can compile c++ in eclipse - Cannot run program "autoreconf": Launching failed
- Why is there no option to set a java project on eclipse to Apache Derby nature?
- Setting up Java + svn + Eclipse+ Tomcat , development environment with docker
- tomcat eclipse error Could not load the Tomcat server configuration at ...The configuration may be corrupt or incomplete
- Receiving broadcast error for Bluetooth discovery - Error in onReceive() method that receives intents by startDiscovery() Method
- File not Found in Project root folder
- iPhone/iPad export Eclipse Plug-ins
- what is the correct file path in eclipse spring
- Manually downloaded Oracle driver but still getting Missing artifact com.oracle:ojdbc6:jar:11.2.0.3:compile
- Using gtkmm with Eclipse CDT
- Changing color of single day in calendarview, android
- An array that will declare 5 random numbers from 0 to 100. Then it will average all the numbers that are over 70
- In Eclipse with m2e, how to get "Quick Javadoc" (F2) to display for Maven dependencies?
- the application myapp(process com.example.package) has stopped unexpectedly please try again
- tabwidget not showing up in eclipse graphical layout editor
- Java 8 and Eclipse on OS X Mavericks
- What is the advised stack to work with Flink and Scala?
- Updating SqlCipher from 1.1 to 2.2.2
- How to use PrimeFaces 3.2 in Eclipse Indigo SR2?
- Android Tutorial issue
- Tomcat page is not coming up when run from eclipse
- gwt maven plugin - unable to run archetype generated sample project in eclipse
- How to distinguish wizards in Eclipse RCP?
- Disable Eclipse plugins?