What is causing this propel error? - database

I'm geting this error in propel when I run my app:
PropelException: Unable to open PDO connection [wrapped: SQLSTATE[HY000] [14] unable to open database file]
I've tried everything I can think of but can't figure out what is causing the problem.
my build.properties is:
propel.project = LinkCannon2
# The Propel driver to use for generating SQL, etc.
propel.database = sqlite
# This must be a PDO DSN
propel.database.url = sqlite://Users/GMan/Public/Source/LinkCannon2/test/data/LinkCannon2TestDB.sq3
propel.addGenericMutators = true
And my runtime-conf.xml is:
<propel>
<datasources default="LinkCannon2">
<datasource id="LinkCannon2"> <!-- this ID must match <database name=""> in schema.xml -->
<adapter>sqlite</adapter> <!-- sqlite, mysql, myssql, oracle, or pgsql -->
<connection>
<classname>DebugPDO</classname>
<dsn>sqlite://localhost///Users/GMan/Public/Source/LinkCannon2/test/data/LinkCannon2TestDB.sq3</dsn>
</connection>
</datasource>
</datasources>
<debugpdo>
<logging>
<details>
<method>
<enabled>true</enabled>
</method>
<time>
<enabled>true</enabled>
</time>
<mem>
<enabled>true</enabled>
</mem>
</details>
</logging>
</debugpdo>
</propel>
</config>

This is not probably not a problem specific to Propel, but to SQLite. If you search for the actual error message (SQLSTATE[HY000] [14] unable to open database file), you will find information about setting the right permissions and all that to make sure the process that executes the PHP script (for example, the Apache server) has access to this file.

Your dsn entry in runtime-conf.xml as well as your url in your build.properties don't seem correct.
Make sure that the patths are correct based on the platform you're using.

Related

SQL Server using Windows Authentication in Wildfly as service

I'm configuring a datasource to use windows authentication with SQL Server.
I put the DLL sqljdbc_auth.dll in C:\Program Files\XXXX\wildfly-10.1.0.Final\bin
Stating Wildfly using standalone.bat works fine.
But using windows service I got this error:
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Cannot open database "Scope_Build36" requested by the login. The login failed. ClientConnectionId:831c2f7f-4352-4467-b54f-a6eb1369d6e9
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:217)
at com.microsoft.sqlserver.jdbc.TDSTokenHandler.onEOF(tdsparser.java:251)
at com.microsoft.sqlserver.jdbc.TDSParser.parse(tdsparser.java:81)
at com.microsoft.sqlserver.jdbc.SQLServerConnection$1LogonProcessor.complete(SQLServerConnection.java:2825)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.sendLogon(SQLServerConnection.java:3079)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(SQLServerConnection.java:2360)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.access$100(SQLServerConnection.java:43)
at com.microsoft.sqlserver.jdbc.SQLServerConnection$LogonCommand.doExecute(SQLServerConnection.java:2346)
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:6276)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1793)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1404)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:1068)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:904)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:451)
at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:1014)
at org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.createLocalManagedConnection(LocalManagedConnectionFactory.java:321)
... 44 more
DataSource configuration:
<datasource jta="true" jndi-name="java:/datasources/PortalScopeWeb_Scope" pool-name="PortalScopeWeb_Scope" enabled="true" use-ccm="true">
<connection-url>jdbc:sqlserver://RI001421D\SQLEXPRESS:1433;databasename=Scope_Build36;integratedSecurity=true</connection-url>
<driver>sqlServer</driver>
<security>
<security-domain>securityDomainPortalScopeWeb_Scope</security-domain>
</security>
<validation>
<check-valid-connection-sql>SELECT 1</check-valid-connection-sql>
<validate-on-match>true</validate-on-match>
<background-validation>false</background-validation>
</validation>
</datasource>
Putting DDL in folder C:\Program Files\XXXX\wildfly-10.1.0.Final\bin\service\amd64 don't solved the problem.
you can use a .udl file to test and verify your connection.
In you desktop create a new .txt file, and rename it like "test.udl". Now, open it, and you can configure and test your connection. When you have the connection ready, you can open the .udl file with notepad and copy connection string.
here you have a reference: udl reference
hope this help!

Connection problems MS SQL 2008 in EAP 6.4

I am new to JBoss EAP and using 6.4 version . Earlier I have been using Tomcat 7.39. I like to shift from tomcat to JBOSS EAP 6.4. From some posts in stack overflow and JBOSS EAP , I some how configure MS SQL 2008 in JBOSS EAP but it is not working .
Standalone.xml File
<subsystem xmlns="urn:jboss:domain:datasources:1.2">
<datasources>
<datasource jndi-name="java:jboss/datasources/TMS" pool-name="TMS" enabled="true" use-java-context="true">
<connection-url>jdbc:sqlserver://localhost:1433;databaseName=TMS;integratedSecurity=false;</connection-url>
<driver>sqlserver</driver>
<security>
<user-name>sa</user-name>
<password>1234</password>
</security>
</datasource>
<drivers>
<driver name="sqlserver" module="com.microsoft.sqlserver">
<xa-datasource-class>com.microsoft.sqlserver.jdbc.SQLServerXADataSource</xa-datasource-class>
</driver>
</drivers>
</datasources>
</subsystem>
Earlier as I do not have any pool-name , I have deleted this attribute from datasource tag. Now I have just kept the pool name as database name though I do not have any pool name yet. Should I have to create pool-name and how could I do that ?
I Created (com\microsoft\sqlserver\main) this folder structure in *EAP_HOME\modules* and Then there I kept sqljdbc4.jar and module.xml. I am using windows 7, 32 bit machine. Below is the code snippet of module.xml:-
<module xmlns="urn:jboss:module:1.1" name="com.microsoft.sqlserver">
<resources>
<resource-root path="sqljdbc4.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
And I am getting this error ERROR com.microsoft.sqlserver.jdbc.SQLServerDriver from [Module "deployment.TSM_UI.war:main" from Service Module Loader]
I am thinking that it might be due to my pool name.Any suggestion. Thanks in Advance
The Error-Message doesn't look complete. I guess it is "ERROR ClassNotFoundEcxeption: Could not load class com.microsoft.sqlserver.jdbc.SQLServerDriver from [Module "deployment.TSM_UI.war:main" from Service Module Loader]" ?
Then you try to load the driver directly from within your deployment, but you should use a JNDI-lookup to get the connection from the datasource you created.
Search your deployment (TSM_UI.war) whether you have any references to com.microsoft.sqlserver.jdbc.SQLServerDriver within your deployment and remove it.

SQL Server connection in Wildfly using JTDS driver

What is the correct way to setup a SQL Server datasource on Widlfly?
I need to access a SQL Server database from my web application which runs on Wildfly.
I have setup the datasource as follows:
<datasource jta="false" jndi-name="java:jboss/db" pool-name="db" enabled="true" use-ccm="false">
<connection-url>jdbc:jtds:sqlserver://IP_ADDRESS;instance=SQLEXPRESS;DatabaseName=DB</connection-url>
<driver-class>net.sourceforge.jtds.jdbc.Driver</driver-class>
<driver>jtds-1.3.1.jar</driver>
</datasource>
This works fine except that when the SQL Server is restarted, the connection is lost and the datasource doesn't manage to recreate one. So I get errors like:
Invalid state, the Connection object is closed.
This post suggests adding some validation, so I did this:
<validation>
<check-valid-connection-sql>SELECT 1</check-valid-connection-sql>
<validate-on-match>false</validate-on-match>
<background-validation>false</background-validation>
</validation>
But that does not solve the problem and I still get the same "connection closed" error from time to time.
This other post suggests using a DataSource instead of a Driver, so I have added this to my configuration:
<datasource-class>net.sourceforge.jtds.jdbcx.JtdsDataSource</datasource-class>
But when I test the connection I get an exception:
java.sql.SQLException: The serverName property has not been set.
at net.sourceforge.jtds.jdbcx.JtdsDataSource.getConnection(JtdsDataSource.java:150)
I was having the same issue after migrating to WFLY and resolved it by adding the properties.
This is what my complete *-ds.xml looks like:
<?xml version="1.0" encoding="UTF-8"?>
<datasources xmlns="http://www.jboss.org/ironjacamar/schema">
<datasource jndi-name="java:/xxxDS" pool-name="MSSQL">
<connection-url>
jdbc:sqlserver://localhost:1433;database=dbname;charset=UTF-8
</connection-url>
<driver>sqljdbc</driver>
<security>
<user-name>xxx</user-name>
<password>xxx</password>
</security>
<pool>
<!-- default is 0 -->
<min-pool-size>10</min-pool-size>
<!-- default is 20 -->
<max-pool-size>50</max-pool-size>
</pool>
<validation>
<valid-connection-checker
class-name="org.jboss.jca.adapters.jdbc.extensions.mssql.MSSQLValidConnectionChecker" />
<validate-on-match>false</validate-on-match>
<background-validation>true</background-validation>
<check-valid-connection-sql>select 1</check-valid-connection-sql>
<background-validation-millis>10000</background-validation-millis>
</validation>
</datasource>
For me, the valid-connection-checker was not adequate, but by adding the background validation with select 1 it was working.
We have moved over to using the jdbc driver directly from MSFT however:
<driver name="sqljdbc" module="mc.jdbc.sqljdbc">
<driver-class>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver-class>
</driver>
That also might make a difference, however we had it set up with JBoss AS7 and the jdts driver for a long time.

How to connect JBoss 7.1.1 Final to Oracle Database?

I looked over the Internet but I couldn't find any easy tutorials or docs explaining the problem.
I want to connect my JBoss 7.1.1 Final to Oracle Database. I am using Oracle Database 11g Express Edition on 64bit Windows.
The question is what should I do to connect my jboss to Oracle DB?
Check this answer jboss 7 oracle datasource configuration
In short, you have to declare a jboss module for your oracle driver.
Then, you create your datasource in standalone-xxx.xml and add the reference to the driver.
Finally, you can use this datasource in any persistence.xml by using the jndi-name declared in the datasource.
All of this is explained in the url provided.
Good luck!
You can create JNDI in Jboss 7.1.1 as below and configure mybatis to use this JNDI. make sure you have oracle driver in Modules at com.oracle.ojdbc localtion.
<subsystem xmlns="urn:jboss:domain:datasources:1.0">
<datasources>
<datasource jta="true" jndi-name="java:/jdbc/test" pool-name="test" enabled="true" use-java-context="true" use-ccm="true">
<connection-url>jdbc:oracle:thin:#localhost:1521:testDB</connection-url>
<driver>oracle</driver>
<pool>
<min-pool-size>2</min-pool-size>
<max-pool-size>100</max-pool-size>
<prefill>false</prefill>
</pool>
<security>
<user-name>username</user-name>
<password>password</password>
</security>
<validation>
<validate-on-match>false</validate-on-match>
<background-validation>false</background-validation>
</validation>
</datasource>
<drivers>
<driver name="oracle" module="com.oracle.ojdbc">
<driver-class>oracle.jdbc.OracleDriver</driver-class>
<xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
</driver>
</drivers>
</datasources>
</subsystem>

From Netbeans Dev to Tomcat Production: DB Connection Not Found

I developed a Java web application in Netbeans 6.5 using a MySQL database and Hibernate. Both the development database server and development application server (Tomcat 6) reside on my development machine. Everything works; the application pulls data from the database correctly.
Now, I'm ready to move it to the production server. Again, the DB server and app server are on the same machine. I deploy the WAR file and try to access the application; I can access the static pages but the Servlets that use the database error out with the exception:
org.hibernate.exception.JDBCConnectionException: Cannot open connection
I'm pretty sure the problem relates to Tomcat not knowing about the data source. It seems as if Netbeans handles this for me. I've read that I might need to add a RESOURCE entry so I took some advice from this site which gave me a context.xml of:
<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" path="/EmployeeDirectory">
<Resource
name="jdbc/employeedirectory" auth="Container"
type="javax.sql.DataSource" username="EmployeeDir"
password="EmployeeDirectory" driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://127.0.0.1:3306/EmployeeDirectory?autoReconnect=true"
maxActive="15" maxIdle="7"
validationQuery="Select 1" />
</Context>
a web.xml of:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<!-- Omit Servlet Info -->
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/employeedirectory</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>
and a hibernate.cfg.xml of:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.datasource">java:comp/env/jdbc/employeedirectory</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<!-- Omit other Mappings -->
<mapping class="EmployeeDirectory.data.PhoneNumber" resource="EmployeeDirectory/data/PhoneNumber.hbm.xml"/>
</session-factory>
</hibernate-configuration>
Now, I get a org.hibernate.HibernateException: Could not find datasource error.
Am I on the right path for moving from development to production? What am I missing?
I think you are on the right track. I would first set up the datasource and verify it out side of hibernate. Here is a good article on that: http://tomcat.apache.org/tomcat-6.0-doc/jndi-resources-howto.htm and some examples here: http://www.mbaworld.com/docs/jndi-datasource-examples-howto.html
Then, I would configure hibernate to use the datsource. From looking at your hibernate.cfg.xml file I think you should try changing hibernate.connection.datasource to jdbc/employeedirectory
the jndi datasource should be defined in /tomcat/server.xml see Tomcat JNDI Datasource how-to and not in webapp/context.xml
Tomcat 6 requires that you add the resource tag to the context.xml, not the server.xml. You could in Tomcat 5.x. I have it working fine in a separate install of Tomcat, but I'm still trying to use connection pooling inside NB 6.5.
That same Apache site has a link to the Tomcat 6 version of JNDI and it tells you to add the resource tag to the context.xml.

Resources